@funnest/charts 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/chart.d.ts CHANGED
@@ -157,6 +157,9 @@ export declare class Chart {
157
157
  private unsubscribeBars;
158
158
  private unsubscribeQuotes;
159
159
  private latestQuote;
160
+ /** Symbol the quote stream belongs to; kept across interval changes of the same symbol. */
161
+ private quoteSymbol;
162
+ private quoteToken;
160
163
  private connectionState;
161
164
  private readonly displayTimezone;
162
165
  private loadingHistory;
package/dist/index.js CHANGED
@@ -2408,6 +2408,9 @@ var Chart = class {
2408
2408
  unsubscribeBars = null;
2409
2409
  unsubscribeQuotes = null;
2410
2410
  latestQuote = null;
2411
+ /** Symbol the quote stream belongs to; kept across interval changes of the same symbol. */
2412
+ quoteSymbol = null;
2413
+ quoteToken = 0;
2411
2414
  connectionState = null;
2412
2415
  displayTimezone;
2413
2416
  loadingHistory = false;
@@ -2510,9 +2513,14 @@ var Chart = class {
2510
2513
  const token = ++this.loadToken;
2511
2514
  this.unsubscribeBars?.();
2512
2515
  this.unsubscribeBars = null;
2513
- this.unsubscribeQuotes?.();
2514
- this.unsubscribeQuotes = null;
2515
- this.latestQuote = null;
2516
+ const keepQuotes = this.unsubscribeQuotes !== null && this.quoteSymbol === symbol;
2517
+ if (!keepQuotes) {
2518
+ this.quoteToken++;
2519
+ this.unsubscribeQuotes?.();
2520
+ this.unsubscribeQuotes = null;
2521
+ this.latestQuote = null;
2522
+ this.quoteSymbol = null;
2523
+ }
2516
2524
  this.emitter.emit("loadingChange", true);
2517
2525
  let info;
2518
2526
  let result;
@@ -2559,11 +2567,15 @@ var Chart = class {
2559
2567
  this.emitter.emit("connectionChange", state);
2560
2568
  }
2561
2569
  );
2562
- this.unsubscribeQuotes = feed.subscribeQuotes?.(info, (quote) => {
2563
- if (token !== this.loadToken) return;
2564
- this.latestQuote = { ...this.latestQuote, ...quote };
2565
- this.emitter.emit("quoteChange", this.latestQuote);
2566
- }) ?? null;
2570
+ if (!keepQuotes) {
2571
+ const quoteToken = ++this.quoteToken;
2572
+ this.quoteSymbol = symbol;
2573
+ this.unsubscribeQuotes = feed.subscribeQuotes?.(info, (quote) => {
2574
+ if (quoteToken !== this.quoteToken) return;
2575
+ this.latestQuote = { ...this.latestQuote, ...quote };
2576
+ this.emitter.emit("quoteChange", this.latestQuote);
2577
+ }) ?? null;
2578
+ }
2567
2579
  this.emitter.emit("symbolChange", info);
2568
2580
  this.stateChanged();
2569
2581
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnest/charts",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Canvas charting engine for financial charts",
5
5
  "keywords": [
6
6
  "chart",