ItemKeyedDataSource
abstract classItemKeyedDataSource<Key : Any, Value : Any> : DataSource<Key, Value>
kotlin.Any | ||
↳ | androidx.paging.DataSource<Key, Value> | |
↳ | androidx.paging.ItemKeyedDataSource |
Incremental data loader for paging keyed content, where loaded content uses previously loaded items as input to future loads.
Implement a DataSource using ItemKeyedDataSource if you need to use data from item N - 1
to load item N
. This is common, for example, in uniquely sorted database queries where
attributes of the item such just before the next query define how to execute it.
The InMemoryByItemRepository
in the
PagingWithNetworkSample
shows how to implement a network ItemKeyedDataSource using
Retrofit, while handling swipe-to-refresh, network errors,
and retry.
Summary
Nested classes | |
---|---|
abstract |
Callback for ItemKeyedDataSource 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 paging keyed content, where loaded content uses previously loaded items as input to future loads. |
Public methods | |
---|---|
abstract Key |
getKey(item: Value) Return a key associated with the given item. |
abstract Unit |
loadAfter(params: ItemKeyedDataSource.LoadParams<Key>, callback: ItemKeyedDataSource.LoadCallback<Value>) Load list data after the key specified in LoadParams.key. |
abstract Unit |
loadBefore(params: ItemKeyedDataSource.LoadParams<Key>, callback: ItemKeyedDataSource.LoadCallback<Value>) Load list data before the key specified in LoadParams.key. |
abstract Unit |
loadInitial(params: ItemKeyedDataSource.LoadInitialParams<Key>, callback: ItemKeyedDataSource.LoadInitialCallback<Value>) Load initial data. |
ItemKeyedDataSource<Key, ToValue> |
Applies the given function to each value emitted by the DataSource. |
ItemKeyedDataSource<Key, ToValue> |
map(function: (Value) -> ToValue) Applies the given function to each value emitted by the DataSource. |
ItemKeyedDataSource<Key, ToValue> |
Applies the given function to each value emitted by the DataSource. |
ItemKeyedDataSource<Key, ToValue> |
Applies the given function to each value emitted by the DataSource. |
Inherited functions | |
---|---|
Inherited properties | |
---|---|
Public constructors
<init>
ItemKeyedDataSource()
Incremental data loader for paging keyed content, where loaded content uses previously loaded items as input to future loads.
Implement a DataSource using ItemKeyedDataSource if you need to use data from item N - 1
to load item N
. This is common, for example, in uniquely sorted database queries where
attributes of the item such just before the next query define how to execute it.
The InMemoryByItemRepository
in the
PagingWithNetworkSample
shows how to implement a network ItemKeyedDataSource 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. |