asPagingItems

fun <T : RealmModel> RealmQueryBuilder<T>.asPagingItems(tag: String = "PagingItemsExecutor", pagingConfig: PagingConfig = DefaultPagingConfig): Flow<PagingData<T>>

Returns Flow<PagingData<T> with results that match the io.realm.RealmQuery produced by the builder.

Note: By default, the implementation copies the entire RealmModel object to memory using RealmCopyTransform. To read a subset of data per RealmModel consider using asPagingItems overload which tasks a RealmModelTransform function.

The flow can be further transformed using paging operators and cached using flow.cachedIn(viewModelScope) in Android ViewModel.

See also

fun <T : RealmModel, R : Any> RealmQueryBuilder<T>.asPagingItems(tag: String = "PagingItemsExecutor", pagingConfig: PagingConfig = DefaultPagingConfig, transform: RealmModelTransform<T, R>): Flow<PagingData<R>>

Returns Flow<PagingData<T> with results that match the io.realm.RealmQuery produced by the builder.

The flow can be further transformed using paging operators and cached using flow.cachedIn(viewModelScope) in Android ViewModel. Note: Thread safety depends on the transform function implementation. Typically the implementation should return unmanaged objects that can be safely passed around threads. For a reference implementation see RealmCopyTransform. As a good practice only read the relevant properties from RealmModel to reduce the amount of objects load into application memory. If managed objects are returned for any reason, no thread safety is guaranteed.

See also