RxRemoteMediator

@ExperimentalPagingApi public abstract class RxRemoteMediator<Key extends Object, Value extends Object> extends RemoteMediator

Object
   ↳ RemoteMediator
     ↳ RxRemoteMediator

RxJava3 compatibility wrapper around RemoteMediator's suspending APIs.

Summary

Public constructors

<Key extends Object, Value extends Object> RxRemoteMediator()

Public methods

final @NonNull RemoteMediator.InitializeAction

Callback fired during initialization of a PagingData stream, before initial load.

@NonNull Single<@NonNull RemoteMediator.InitializeAction>

Callback fired during initialization of a PagingData stream, before initial load.

final @NonNull 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:

abstract @NonNull Single<@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.

Public constructors

RxRemoteMediator

public final <Key extends Object, Value extends Object> RxRemoteMediator()

Public methods

initialize

@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

InitializeAction used to control whether load with load type REFRESH will be immediately dispatched when the first PagingData is submitted:

initializeSingle

@NonNull
public Single<@NonNull RemoteMediator.InitializeActioninitializeSingle()

Callback fired during initialization of a PagingData stream, before initial load.

This function runs to completion before any loading is performed.

Returns
Single<@NonNull RemoteMediator.InitializeAction>

InitializeAction indicating the action to take after initialization:

load

@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