{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}
public abstract class RxRemoteMediator<Key extends Object, Value extends Object> extends RemoteMediator
RxJava2 compatibility wrapper around RemoteMediator
's suspending APIs.
Public constructors |
|
---|---|
<Key extends Object, Value extends Object> RxRemoteMediator() |
Public methods |
|
---|---|
final @NonNull RemoteMediator.InitializeAction |
Callback fired during initialization of a |
@NonNull <ERROR CLASS><@NonNull RemoteMediator.InitializeAction> |
Callback fired during initialization of a |
final @NonNull RemoteMediator.MediatorResult |
Callback triggered when Paging needs to request more data from a remote source due to any of the following events: |
abstract @NonNull <ERROR CLASS><@NonNull RemoteMediator.MediatorResult> |
loadSingle( Implement this method to load additional remote data, which will then be stored for the |
@NonNull
public final RemoteMediator.InitializeAction initialize()
Callback fired during initialization of a PagingData
stream, before initial load.
This function runs to completion before any loading is performed.
Returns | |
---|---|
RemoteMediator.InitializeAction |
|
@NonNull
public <ERROR CLASS><@NonNull RemoteMediator.InitializeAction> initializeSingle()
Callback fired during initialization of a PagingData
stream, before initial load.
This function runs to completion before any loading is performed.
Returns | |
---|---|
<ERROR CLASS><@NonNull RemoteMediator.InitializeAction> |
|
@NonNull
public final RemoteMediator.MediatorResult load(
@NonNull LoadType loadType,
@NonNull PagingState<@NonNull Key, @NonNull Value> state
)
Callback triggered when Paging needs to request more data from a remote source due to any of the following events:
Stream initialization if initialize
returns LAUNCH_INITIAL_REFRESH
REFRESH
signal driven from UI
PagingSource
returns a LoadResult which signals a boundary condition, i.e., the most recent LoadResult.Page in the PREPEND
or APPEND
direction has LoadResult.Page.prevKey or LoadResult.Page.nextKey set to null
respectively.
It is the responsibility of this method to update the backing dataset and trigger PagingSource.invalidate
to allow androidx.paging.PagingDataAdapter
to pick up new items found by load
.
The runtime and result of this method defines the remote LoadState
behavior sent to the UI via CombinedLoadStates.
This method is never called concurrently unlessPager.flow has multiple collectors. Note that Paging might cancel calls to this function if it is currently executing a PREPEND
or APPEND
and a REFRESH
is requested. In that case, REFRESH
has higher priority and will be executed after the previous call is cancelled. If the load
call with REFRESH
returns an error, Paging will call load
with the previously cancelled APPEND
or PREPEND
request. If REFRESH
succeeds, it won't make the APPEND
or PREPEND
requests unless they are necessary again after the REFRESH
is applied to the UI.
Parameters | |
---|---|
@NonNull LoadType loadType |
|
@NonNull PagingState<@NonNull Key, @NonNull Value> state |
A copy of the state including the list of pages currently held in memory of the currently presented |
Returns | |
---|---|
RemoteMediator.MediatorResult |
|
@NonNull
public abstract <ERROR CLASS><@NonNull RemoteMediator.MediatorResult> loadSingle(
@NonNull LoadType loadType,
@NonNull PagingState<@NonNull Key, @NonNull Value> state
)
Implement this method to load additional remote data, which will then be stored for the PagingSource
to access. These loads take one of two forms:
type == LoadType.PREPEND
/ LoadType.APPEND
The PagingSource
has loaded a 'boundary' page, with a null
adjacent key. This means this method should load additional remote data to append / prepend as appropriate, and store it locally.
type == LoadType.REFRESH
The app (or initialize
) has requested a remote refresh of data. This means the method should generally load remote data, and replace all local data.
The runtime of this method defines loading state behavior in boundary conditions, which affects e.g., LoadState
callbacks registered to androidx.paging.PagingDataAdapter
.
NOTE: A PagingSource.load
request which is fulfilled by a page that hits a boundary condition in either direction will trigger this callback with LoadType.PREPEND
or LoadType.APPEND
or both. LoadType.REFRESH
occurs as a result of initialize
.
Parameters | |
---|---|
@NonNull LoadType loadType |
|
@NonNull PagingState<@NonNull Key, @NonNull Value> state |
A copy of the state including the list of pages currently held in memory of the currently presented |
Returns | |
---|---|
<ERROR CLASS><@NonNull RemoteMediator.MediatorResult> |
|