MirroredIviDataSource

class MirroredIviDataSource<E : Any, Q : Any>(ipc: IviDataSourceIpc<E, Q>, connectionScope: CoroutineScope) : IviDataSource<E, Q>

Mirrors another IviDataSource. The mirrored IviDataSource is accessed through ipc.

When an IviPagingSource is created through createPagingSource or createPagingSourceFlow, a MirroredIviPagingSource is created. The mirrored IviDataSource creates an corresponding IviPagingSource on the first MirroredIviPagingSource.load call. Both the MirroredIviPagingSource and the corresponding IviPagingSource created by the mirrored IviDataSource are invalidated when either is invalidated.

Constructors

Link copied to clipboard
fun <E : Any, Q : Any> MirroredIviDataSource(ipc: IviDataSourceIpc<E, Q>, connectionScope: CoroutineScope)

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

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
open override fun createPagingSource(query: Q, lifecycleOwner: LifecycleOwner): IviPagingSource<E>

Creates an IviPagingSource for the given query. The page source is invalidated when the given lifecycleOwner is destroyed.

Link copied to clipboard
open 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.