IviDataSource

interface IviDataSource<E : Any, Q : Any>

Interface of all IVI data source implementations.

This type is supported in IVI service interfaces.

An IVI data source can be used to expose a data set to clients without requiring the full data set to be loaded in memory. It also allows querying and sorting data on the service side.

An IVI data source can be used to create one or more IviPagingSources. The IviPagingSources can be used to load data pages from the data source. Each IviPagingSource is bound to a query.

When the data of the IVI data source is modified, active IviPagingSources need to be invalidated. A new IviPagingSource instance needs to be created afterwards. To simplify the latter, at the client side various LiveData and Flow extensions exist to re-create IviPagingSources instances automatically and handle the invalidation, even while loading pages.

The IviPagingSource is designed to seamlessly integrate with the Android Paging library. This makes it possible to represent E elements in a RecyclerView. The platform_framework_api_ipc_iviserviceandroidpaging modules contains extensions functions for the integration.

Parameters

E

Element type exposed by the data source. Any immutable type supported by the IVI service framework. See IviService annotation.

Q

Query type. Any immutable type supported by the IVI service framework.

Inheritors

Properties

Link copied to clipboard

true if this IviDataSource supports jumping, false otherwise.

Link copied to clipboard

true if IviPagingSource created by createPagingSource or createPagingSourceFlow expects to re-use keys to load distinct pages without a call to invalidate, false otherwise. See PagingSource.keyReuseSupported for details.

Functions

Link copied to clipboard
abstract fun createPagingSource(query: Q, coroutineScope: CoroutineScope): IviPagingSource<E>

Creates an IviPagingSource for the given query. The page source is invalidated when the given coroutineScope is cancelled.

Link copied to clipboard
abstract fun createPagingSourceFlow(query: Q): Flow<IviPagingSource<E>>

Same as createPagingSource except that this variant returns a Flow. The benefit of this variant is that it does not require a LifecycleOwner as we can use the Flow cancellation to invalidate the IviPagingSource. This variant is ideal for creating a Flow/LiveData transformation.