EntityFeedProvider

A custom provider of dynamic entity feed data.

The provider is used by CustomDynamicEntityDataSource in the following way:

  • When a connection needs to be established (for example, due to a DynamicEntityDataSource.connect call or an implicit a reconnection), onLoad will first be called (if the data source isn't already loaded) to retrieve metadata about the data source.

  • onConnect will then be called. At this point the provider should begin connecting to whatever data it is going to use. If the initial connection fails then it should throw from this method. If not, it should begin sending events into feed, for example by launching a coroutine that communicates with some external server and forwards the data it receives. Note that it's advisable to wait until the connection status of the data source changes to ConnectionStatus.Connected to ensure that no events are missed by the data source.

  • The data source will begin listening to events from feed. A description of what each event does is given in the doc of the FeedEvent hierarchy.

  • If DynamicEntityDataSource.disconnect is called then onDisconnect will be called on the provider and the data source will stop listening for events. During onDisconnect the provider should tear down things that it set up during onConnect.

It is not possible to use kotlinx.coroutines.flow.flow builder directly as a feed but it can be used indirectly by first sharing it into a SharedFlow using kotlinx.coroutines.flow.shareIn. Using this workflow, the onConnect and onDisconnect callbacks are likely to be empty.

Since

200.2.0

Properties

Link copied to clipboard

A SharedFlow of FeedEvents which the CustomDynamicEntityDataSource will listen to when its connection status is ConnectionStatus.Connected.

Functions

Link copied to clipboard
abstract suspend fun onConnect()

Handles the connection process of a data source.

Link copied to clipboard
abstract suspend fun onDisconnect()

Handles the disconnection process of a data source.

Link copied to clipboard
abstract suspend fun onLoad(): DynamicEntityDataSourceInfo

Handles the loading process of a data source and returns DynamicEntityDataSourceInfo.