# RxRemoteMediator

Artifact: [androidx.paging:paging-rxjava3](https://developer.android.com/jetpack/androidx/releases/paging) [View Source](https://cs.android.com/search?q=file:androidx/paging/rxjava3/RxRemoteMediator.kt+class:androidx.paging.rxjava3.RxRemoteMediator) Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

*** ** * ** ***


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

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.paging.RemoteMediator](https://developer.android.com/reference/androidx/paging/RemoteMediator)\<@[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull) Key, @[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull) Value\> ||
|   | ↳ | [androidx.paging.rxjava3.RxRemoteMediator](https://developer.android.com/reference/androidx/paging/rxjava3/RxRemoteMediator) |

*** ** * ** ***

RxJava3 compatibility wrapper around `https://developer.android.com/reference/androidx/paging/RemoteMediator`'s suspending APIs.

## Summary

| ### Public constructors |
|---|
| `<Key extends https://developer.android.com/reference/java/lang/Object.html, Value extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/paging/rxjava3/RxRemoteMediator#RxRemoteMediator()()` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/RemoteMediator.InitializeAction` | `https://developer.android.com/reference/androidx/paging/rxjava3/RxRemoteMediator#initialize()()` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Single.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/RemoteMediator.InitializeAction>` | `https://developer.android.com/reference/androidx/paging/rxjava3/RxRemoteMediator#initializeSingle()()` Callback fired during initialization of a `https://developer.android.com/reference/androidx/paging/PagingData` stream, before initial load. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/RemoteMediator.MediatorResult` | `https://developer.android.com/reference/androidx/paging/rxjava3/RxRemoteMediator#load(androidx.paging.LoadType,androidx.paging.PagingState)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/LoadType loadType, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingState<@https://developer.android.com/reference/androidx/annotation/NonNull Key, @https://developer.android.com/reference/androidx/annotation/NonNull Value> state )` |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Single.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/RemoteMediator.MediatorResult>` | `https://developer.android.com/reference/androidx/paging/rxjava3/RxRemoteMediator#loadSingle(androidx.paging.LoadType,androidx.paging.PagingState)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/LoadType loadType, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingState<@https://developer.android.com/reference/androidx/annotation/NonNull Key, @https://developer.android.com/reference/androidx/annotation/NonNull Value> state )` Implement this method to load additional remote data, which will then be stored for the `https://developer.android.com/reference/androidx/paging/PagingSource` to access. |

## Public constructors

### RxRemoteMediator

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

## Public methods

### initialize

```
public final @NonNull RemoteMediator.InitializeAction initialize()
```

### initializeSingle

Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

```
public @NonNull Single<@NonNull RemoteMediator.InitializeAction> initializeSingle()
```

Callback fired during initialization of a `https://developer.android.com/reference/androidx/paging/PagingData` stream, before initial load.

This function runs to completion before any loading is performed.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Single.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/RemoteMediator.InitializeAction>` | `https://developer.android.com/reference/androidx/paging/RemoteMediator.InitializeAction` indicating the action to take after initialization: \* `https://developer.android.com/reference/androidx/paging/RemoteMediator.InitializeAction#LAUNCH_INITIAL_REFRESH` to immediately dispatch a `https://developer.android.com/reference/androidx/paging/rxjava3/RxRemoteMediator#load(androidx.paging.LoadType,androidx.paging.PagingState)` asynchronously with load type `https://developer.android.com/reference/androidx/paging/LoadType#REFRESH`, to update paginated content when the stream is initialized. Note: This also prevents `https://developer.android.com/reference/androidx/paging/RemoteMediator` from triggering `https://developer.android.com/reference/androidx/paging/LoadType#PREPEND` or `https://developer.android.com/reference/androidx/paging/LoadType#APPEND` until `https://developer.android.com/reference/androidx/paging/LoadType#REFRESH` succeeds. \* `https://developer.android.com/reference/androidx/paging/RemoteMediator.InitializeAction#SKIP_INITIAL_REFRESH` to wait for a refresh request from the UI before dispatching a `https://developer.android.com/reference/androidx/paging/rxjava3/RxRemoteMediator#load(androidx.paging.LoadType,androidx.paging.PagingState)` with load type `https://developer.android.com/reference/androidx/paging/LoadType#REFRESH`. |

### load

```
public final @NonNull RemoteMediator.MediatorResult load(
    @NonNull LoadType loadType,
    @NonNull PagingState<@NonNull Key, @NonNull Value> state
)
```

### loadSingle

Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

```
public 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 `https://developer.android.com/reference/androidx/paging/PagingSource` to access. These loads take one of two forms: \* type == `https://developer.android.com/reference/androidx/paging/LoadType#PREPEND` / `https://developer.android.com/reference/androidx/paging/LoadType#APPEND` The `https://developer.android.com/reference/androidx/paging/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 == `https://developer.android.com/reference/androidx/paging/LoadType#REFRESH` The app (or `https://developer.android.com/reference/androidx/paging/rxjava3/RxRemoteMediator#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., `https://developer.android.com/reference/androidx/paging/LoadState` callbacks registered to `https://developer.android.com/reference/androidx/paging/PagingDataAdapter`.

NOTE: A `https://developer.android.com/reference/androidx/paging/PagingSource#load(androidx.paging.PagingSource.LoadParams)` request which is fulfilled by a page that hits a boundary condition in either direction will trigger this callback with `https://developer.android.com/reference/androidx/paging/LoadType#PREPEND` or `https://developer.android.com/reference/androidx/paging/LoadType#APPEND` or both. `https://developer.android.com/reference/androidx/paging/LoadType#REFRESH` occurs as a result of `https://developer.android.com/reference/androidx/paging/rxjava3/RxRemoteMediator#initialize()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/LoadType loadType` | `https://developer.android.com/reference/androidx/paging/LoadType` of the boundary condition which triggered this callback. \* `https://developer.android.com/reference/androidx/paging/LoadType#PREPEND` indicates a boundary condition at the front of the list. \* `https://developer.android.com/reference/androidx/paging/LoadType#APPEND` indicates a boundary condition at the end of the list. \* `https://developer.android.com/reference/androidx/paging/LoadType#REFRESH` indicates this callback was triggered as the result of a requested refresh - either driven by the UI, or by `https://developer.android.com/reference/androidx/paging/rxjava3/RxRemoteMediator#initialize()`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingState<@https://developer.android.com/reference/androidx/annotation/NonNull Key, @https://developer.android.com/reference/androidx/annotation/NonNull Value> state` | A copy of the state including the list of pages currently held in memory of the currently presented `https://developer.android.com/reference/androidx/paging/PagingData` at the time of starting the load. E.g. for load(loadType = END), you can use the page or item at the end as input for what to load from the network. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Single.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/RemoteMediator.MediatorResult>` | `https://developer.android.com/reference/androidx/paging/RemoteMediator.MediatorResult` signifying what `https://developer.android.com/reference/androidx/paging/LoadState` to be passed to the UI, and whether there's more data available. |