PageKeyedDataSource
abstract classPageKeyedDataSource<Key : Any, Value : Any> : DataSource<Key, Value>
kotlin.Any | ||
↳ | androidx.paging.DataSource<Key, Value> | |
↳ | androidx.paging.PageKeyedDataSource |
Incremental data loader for page-keyed content, where requests return keys for next/previous pages.
Implement a DataSource using PageKeyedDataSource if you need to use data from page N - 1
to
load page N
. This is common, for example, in network APIs that include a next/previous link or
key with each page load.
The InMemoryByPageRepository
in the
PagingWithNetworkSample
shows how to implement a network PageKeyedDataSource using
Retrofit, while
handling swipe-to-refresh, network errors, and retry.
Summary
Nested classes | |
---|---|
abstract |
Callback for loadBefore and loadAfter to return data. |
abstract |
Callback for loadInitial to return data and, optionally, position/count information. |
open |
Holder object for inputs to loadInitial. |
open |
Holder object for inputs to loadBefore and loadAfter. |
Public constructors | |
---|---|
<init>() Incremental data loader for page-keyed content, where requests return keys for next/previous pages. |
Public methods | |
---|---|
abstract Unit |
loadAfter(params: PageKeyedDataSource.LoadParams<Key>, callback: PageKeyedDataSource.LoadCallback<Key, Value>) Append page with the key specified by LoadParams.key. |
abstract Unit |
loadBefore(params: PageKeyedDataSource.LoadParams<Key>, callback: PageKeyedDataSource.LoadCallback<Key, Value>) Prepend page with the key specified by LoadParams.key. |
abstract Unit |
loadInitial(params: PageKeyedDataSource.LoadInitialParams<Key>, callback: PageKeyedDataSource.LoadInitialCallback<Key, Value>) Load initial data. |
PageKeyedDataSource<Key, ToValue> |
Applies the given function to each value emitted by the DataSource. |
PageKeyedDataSource<Key, ToValue> |
map(function: (Value) -> ToValue) Applies the given function to each value emitted by the DataSource. |
PageKeyedDataSource<Key, ToValue> |
Applies the given function to each value emitted by the DataSource. |
PageKeyedDataSource<Key, ToValue> |
Applies the given function to each value emitted by the DataSource. |
Inherited functions | |
---|---|
Inherited properties | |
---|---|
Public constructors
<init>
PageKeyedDataSource()
Incremental data loader for page-keyed content, where requests return keys for next/previous pages.
Implement a DataSource using PageKeyedDataSource if you need to use data from page N - 1
to
load page N
. This is common, for example, in network APIs that include a next/previous link or
key with each page load.
The InMemoryByPageRepository
in the
PagingWithNetworkSample
shows how to implement a network PageKeyedDataSource using
Retrofit, while
handling swipe-to-refresh, network errors, and retry.
Parameters | |
---|---|
Key |
Type of data used to query Value types out of the DataSource. |
Value |
Type of items being loaded by the DataSource. |
Public methods
loadAfter
abstract fun