A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://nagix.github.io/chartjs-plugin-streaming/master/guide/data-feed-models.html below:

Website Navigation


Data Feed Models | chartjs-plugin-streaming

# Data Feed Models

This plugin supports both pull and push based data feed.

# Pull Model (Polling Based) - Synchronous

In the pull model, the user code needs to ask for new data and pull it from a data source. To enable this, the plugin provides two options: onRefresh which is the callback function that is called at a regular interval to check the data source and refresh which specifies the interval. In this callback function, you can add data into the existing data array as usual, but you don't need to call the update function as it is called internally.

For example:

# Pull Model (Polling Based) - Asynchronous

If your data source responds to requests asynchronously, you will probably receive the results in a callback function in which you can add data into the existing data array. The update function needs to be called after adding new data.

A problem with calling the update function for stream data feeds is that it can disrupt smooth transition because an update call interrupts the current animation and initiates a new one. To avoid this, this plugin added the 'quiet' transition mode for the update function. If it is specified, the current animation won't be interrupted and new data can be added without initiating a new animation.

This model is suitable for data sources such as web servers, Kafka (REST Proxy), Kinesis (Data Streams API) and other time series databases with REST API support including Elasticsearch, OpenTSDB and Graphite.

For example:

# Push Model (Listening Based)

In the push model, the user code registers a listener that waits for new data, and data can be picked up immediately after it arrives. Usually, data source connector libraries that support the push model provide a listener callback function in which you can add data into the existing data array. onRefresh is unnecessary in this model, but the update function needs to be called after adding new data like asynchronous pull model.

This model is suitable for data sources such as WebSocket, MQTT, Kinesis (Client Library) and other realtime messaging services including Socket.IO, Pusher and Firebase.

Here is an example of a listener function:

Last Updated: 6/19/2021, 6:53:43 AM


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4