Skip to content

charton API


charton API / @chart-on/core / index / createPollingDataSource

Function: createPollingDataSource() ​

createPollingDataSource(options): DataSource

Defined in: packages/core/src/data/adapters.ts:191

Live bars for HTTP-only sources: polls the history source's history method for the newest bars and streams them as if they came from a socket. Each poll is a 'refresh' request from the newest bar seen (the first poll has no from). The rule follows the chart's streaming contract, where a bar with the last time replaces it and a newer one appends:

  • each poll sends, oldest first, every bar that is new or differs from the version sent last, so a late trade in the previous bar arrives before the next bar opens, and nothing unchanged is sent again;
  • if the bar sent last is missing from the response (e.g. after the tab slept and more than limit bars opened), the bars in between were missed, so the source reports a reset from it through onReset, and the chart refetches the gap; the response's bars are still sent. A failed poll reports reconnecting through onStatus, and the next good one connected, after which the chart refetches what it missed.

Parameters ​

options ​

PollingDataSourceOptions

Returns ​

DataSource