Загрузка данных


private scheduleHistoryBatch = () => {
  if (this.historyBatchRunning) {
    return;
  }

  const previousRange = this.lwcChart.timeScale().getVisibleLogicalRange();

  this.historyBatchRunning = true;

  requestAnimationFrame(() => {
    const symbolIds = this.activeSymbolIds.slice();

    Promise.all(symbolIds.map((symbolId) => this.dataSource.loadMoreHistory(symbolId))).finally(() => {
      this.historyBatchRunning = false;

      const currentRange = this.lwcChart.timeScale().getVisibleLogicalRange();

      if (!previousRange || !currentRange) {
        return;
      }

      const historyRangeChanged = currentRange.from !== previousRange.from;

      if (historyRangeChanged && currentRange.from < HISTORY_LOAD_THRESHOLD) {
        this.scheduleHistoryBatch();
      }
    });
  });
};