MutableIviDataSource

abstract class MutableIviDataSource<E : Any, Q : Any>(val jumpingSupported: Boolean) : IviDataSource<E, Q>

Base class for IviDataSource implementations that contains the code to load data from a data source.

When the data source is changed, invalidateAllPagingSources can be called to invalidate all active MutableIviPagingSource. This will inform all clients about the invalidation. This allows clients to recreate the MutableIviPagingSource.

Constructors

Link copied to clipboard
constructor(jumpingSupported: Boolean)

Properties

Link copied to clipboard
open override val jumpingSupported: Boolean

true if this IviDataSource supports jumping, false otherwise.

Link copied to clipboard
open override val keyReuseSupported: Boolean = false

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
override 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
override 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.

Link copied to clipboard

Utility function to invalidate all created MutableIviPagingSources. This is to be called when the data set is changed.