Release v23.038 (from e012cb8f)
Fixes tradingview/charting_library#4522 Fixes tradingview/charting_library#5348 Fixes tradingview/charting_library#5573 Fixes tradingview/charting_library#5726 Fixes tradingview/charting_library#6039 Fixes tradingview/charting_library#6215 Fixes tradingview/charting_library#6500 Fixes tradingview/charting_library#6550 Fixes tradingview/charting_library#6559 Fixes tradingview/charting_library#6572 Fixes tradingview/charting_library#6617 Fixes tradingview/charting_library#6659 Fixes tradingview/charting_library#6678 Fixes tradingview/charting_library#6695 Fixes tradingview/charting_library#6713 Fixes tradingview/charting_library#6714 Fixes tradingview/charting_library#6737 Fixes tradingview/charting_library#6767 Fixes tradingview/charting_library#6783 Fixes tradingview/charting_library#6800 Fixes tradingview/charting_library#6825
This commit is contained in:
@@ -3,9 +3,8 @@ export class QuotesPulseProvider {
|
||||
constructor(quotesProvider) {
|
||||
this._subscribers = {};
|
||||
this._requestsPending = 0;
|
||||
this._timers = null;
|
||||
this._quotesProvider = quotesProvider;
|
||||
setInterval(this._updateQuotes.bind(this, 1 /* Fast */), 10000 /* Fast */);
|
||||
setInterval(this._updateQuotes.bind(this, 0 /* General */), 60000 /* General */);
|
||||
}
|
||||
subscribeQuotes(symbols, fastSymbols, onRealtimeCallback, listenerGuid) {
|
||||
this._subscribers[listenerGuid] = {
|
||||
@@ -13,12 +12,30 @@ export class QuotesPulseProvider {
|
||||
fastSymbols: fastSymbols,
|
||||
listener: onRealtimeCallback,
|
||||
};
|
||||
this._createTimersIfRequired();
|
||||
logMessage(`QuotesPulseProvider: subscribed quotes with #${listenerGuid}`);
|
||||
}
|
||||
unsubscribeQuotes(listenerGuid) {
|
||||
delete this._subscribers[listenerGuid];
|
||||
if (Object.keys(this._subscribers).length === 0) {
|
||||
this._destroyTimers();
|
||||
}
|
||||
logMessage(`QuotesPulseProvider: unsubscribed quotes with #${listenerGuid}`);
|
||||
}
|
||||
_createTimersIfRequired() {
|
||||
if (this._timers === null) {
|
||||
const fastTimer = setInterval(this._updateQuotes.bind(this, 1 /* SymbolsType.Fast */), 10000 /* UpdateTimeouts.Fast */);
|
||||
const generalTimer = setInterval(this._updateQuotes.bind(this, 0 /* SymbolsType.General */), 60000 /* UpdateTimeouts.General */);
|
||||
this._timers = { fastTimer, generalTimer };
|
||||
}
|
||||
}
|
||||
_destroyTimers() {
|
||||
if (this._timers !== null) {
|
||||
clearInterval(this._timers.fastTimer);
|
||||
clearInterval(this._timers.generalTimer);
|
||||
this._timers = null;
|
||||
}
|
||||
}
|
||||
_updateQuotes(updateType) {
|
||||
if (this._requestsPending > 0) {
|
||||
return;
|
||||
@@ -26,7 +43,7 @@ export class QuotesPulseProvider {
|
||||
for (const listenerGuid in this._subscribers) { // tslint:disable-line:forin
|
||||
this._requestsPending++;
|
||||
const subscriptionRecord = this._subscribers[listenerGuid];
|
||||
this._quotesProvider.getQuotes(updateType === 1 /* Fast */ ? subscriptionRecord.fastSymbols : subscriptionRecord.symbols)
|
||||
this._quotesProvider.getQuotes(updateType === 1 /* SymbolsType.Fast */ ? subscriptionRecord.fastSymbols : subscriptionRecord.symbols)
|
||||
.then((data) => {
|
||||
this._requestsPending--;
|
||||
if (!this._subscribers.hasOwnProperty(listenerGuid)) {
|
||||
|
||||
Reference in New Issue
Block a user