pageable

fun <Key : Any, PageItem : Any> pageable(coroutineScope: CoroutineScope, onPage: Unit.(key: Key) -> Flow<List<PageItem>?>, strategy: PageFetchStrategy<Key, PageItem, Unit>, initialItems: List<PageItem> = emptyList(), pageItemKey: (PageItem) -> Any = { it }): Pageable<Key, PageItem>

Creates an empty-context Pageable.

Parameters

coroutineScope

Scope that will be used for all the work.

onPage

Factory of page flows. A page that is empty is treated as valid, a page that is null is treated as loading.

strategy

Strategy for compositing a list of pages to load.

initialItems

Items that will be displayed before any page data is collected.

pageItemKey

Key factory for tracking items in storage and UI.


fun <Key : Any, PageItem : Any, Context> pageable(coroutineScope: CoroutineScope, context: StateFlow<Context>, onPage: Context.(key: Key) -> Flow<List<PageItem>?>, strategy: PageFetchStrategy<Key, PageItem, Context>, initialItems: List<PageItem> = emptyList(), pageItemKey: (PageItem) -> Any = { it }): Pageable<Key, PageItem>

Creates a Pageable that can react to changes in the provided context.

When the context emits a new value, any currently cached pages are invalidated and re-fetched.

Parameters

coroutineScope

Scope that will be used for all the work.

context

Context for page updates and strategy calculations. Context changes trigger a reload.

onPage

Factory of page flows. A page that is empty is treated as valid, a page that is null is treated as loading.

strategy

Strategy for compositing a list of pages to load.

initialItems

Items that will be displayed before any page data is collected.

pageItemKey

Key factory for tracking items in storage and UI.