I am trying to find an easy way to call parent function from child one. However, couldn't really found a way to directly call it from child instance as like in other programming languages.
class ExchangeHandler {
constructor(getMarketsUrl, getMarketDataBaseUrl, interval) {
this.interval = interval;
this.getMarketsUrl = getMarketDataBaseUrl;
this.getMarketDataBaseUrl = getMarketDataBaseUrl;
}
getMarketsUrl() {
return this.getMarketsUrl;
}
getMarketDataBaseUrl() {
return this.getMarketDataBaseUrl;
}
buildQueryUrl(params) {
return querystring.stringify(params);
}
getIntervalParam() {
return config.intervalToExchangeInput[[config.exchange]][[this.interval]];
}
}
class BittrexHandler extends ExchangeHandler {
constructor(interval) {
super("https://bittrex.com/api/v1.1/public/getmarkets",
"https://bittrex.com/Api/v2.0/pub/market/GetTicks",
interval);
}
buildGetMarketTickerUrl(symbol) {
return super.getMarketDataBaseUrl() + "?"
+ super.buildQueryUrl({marketName: this.buildSymbolParam(symbol),
tickInterval: super.getIntervalParam()})
}
buildSymbolParam(symbol) {
return "BTC-" + symbol;
}
}
var bittrexHandler = ExchangeHandlerFactory.getExchangeHandler("bittrex", "hour");
console.log("getMarketsUrl: " + bittrexHandler.getMarketsUrl());
And I get
TypeError: bittrexHandler.getMarketsUrl is not a function
Isn't this possible in javascript? Thanks a lot!