Pager

public final class Pager<Key extends Object, Value extends Object>


Primary entry point into Paging; constructor for a reactive stream of PagingData.

Each PagingData represents a snapshot of the backing paginated data. Updates to the backing dataset should be represented by a new instance of PagingData.

PagingSource.invalidate and calls to AsyncPagingDataDiffer.refresh or PagingDataAdapter.refresh will notify Pager that the backing dataset has been updated and a new PagingData / PagingSource pair will be generated to represent an updated snapshot.

PagingData can be transformed to alter data as it loads, and presented in a RecyclerView via AsyncPagingDataDiffer or PagingDataAdapter.

LiveData support is available as an extension property provided by the androidx.paging:paging-runtime artifact.

RxJava support is available as extension properties provided by the androidx.paging:paging-rxjava2 artifact.

Summary

Public fields

final @NonNull Flow<@NonNull PagingData<@NonNull Value>>

A cold Flow of PagingData, which emits new instances of PagingData once they become invalidated by PagingSource.invalidate or calls to AsyncPagingDataDiffer.refresh or PagingDataAdapter.refresh.

Public constructors

<Key extends Object, Value extends Object> Pager(
    @NonNull PagingConfig config,
    @Nullable Key initialKey,
    @NonNull Function0<@NonNull PagingSource<@NonNull Key, @NonNull Value>> pagingSourceFactory
)
<Key extends Object, Value extends Object> Pager(
    @NonNull PagingConfig config,
    @Nullable Key initialKey,
    @Nullable RemoteMediator<@NonNull Key, @NonNull Value> remoteMediator,
    @NonNull Function0<@NonNull PagingSource<@NonNull Key, @NonNull Value>> pagingSourceFactory
)

Public fields

flow

@NonNull
public final @NonNull Flow<@NonNull PagingData<@NonNull Value>> flow

A cold Flow of PagingData, which emits new instances of PagingData once they become invalidated by PagingSource.invalidate or calls to AsyncPagingDataDiffer.refresh or PagingDataAdapter.refresh.

Public constructors

Pager

public final <Key extends Object, Value extends Object> Pager(
    @NonNull PagingConfig config,
    @Nullable Key initialKey,
    @NonNull Function0<@NonNull PagingSource<@NonNull Key, @NonNull Value>> pagingSourceFactory
)

Pager

@ExperimentalPagingApi
public final <Key extends Object, Value extends Object> Pager(
    @NonNull PagingConfig config,
    @Nullable Key initialKey,
    @Nullable RemoteMediator<@NonNull Key, @NonNull Value> remoteMediator,
    @NonNull Function0<@NonNull PagingSource<@NonNull Key, @NonNull Value>> pagingSourceFactory
)