PagingEventEmitter

class PagingEventEmitter

This class exposes an eventFlow ready to be consumed by Pager It's a Helper class to be used in the UI layer. Calling onGetItem by giving the index of the currently displayed item will trigger the fetching and prefetching of data based on Pager configuration and state.

Constructors

Link copied to clipboard
fun PagingEventEmitter()

Functions

Link copied to clipboard
fun onGetItem(index: Int)

Will trigger the fetching and prefetching of data based on Pager configuration and state. This has to be called when the data at the index provided is being displayed (for instance when binding data and view in a list adapter logic)

Link copied to clipboard
fun retry()

Will retry the fetching of data in case of Error

Link copied to clipboard
fun stop()

Will request the pager to stop reacting to eventFlow. This must be called when the screen displaying the list is not visible anymore. The paging operation can be restored by calling Pager.subscribeToViewEvents

Properties

Link copied to clipboard
var bottomItemOffset: Int = 0

This can be used to prevent loading un-needed data when calling onGetItem for an index which is not data, such as a bottom loading view. Value of 0 (default) will have no effect

Link copied to clipboard
val eventFlow: MutableSharedFlow<PagingViewEvent>

Hot flow of PagingViewEvent, to be consumed by Pager

Link copied to clipboard
var listSize: Int = 0

This is the list size used to discard event based on the previous parameter. This is not taken into account if bottomItemOffset is 0