# RxRemoteMediator

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

*** ** * ** ***


```
@ExperimentalPagingApi
abstract class RxRemoteMediator<Key : Any, Value : Any> : RemoteMediator<Key, Value>
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.paging.RemoteMediator](https://developer.android.com/reference/kotlin/androidx/paging/RemoteMediator)\<Key, Value\> ||
|   | ↳ | [androidx.paging.rxjava2.RxRemoteMediator](https://developer.android.com/reference/kotlin/androidx/paging/rxjava2/RxRemoteMediator) |

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `<Key : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html, Value : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/paging/rxjava2/RxRemoteMediator#RxRemoteMediator()()` |

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

## Public constructors

### RxRemoteMediator

```
<Key : Any, Value : Any> RxRemoteMediator()
```

## Public functions

### initialize

```
final suspend fun initialize(): RemoteMediator.InitializeAction
```

### initializeSingle

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

```
open fun initializeSingle(): Single<RemoteMediator.InitializeAction>
```

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

This function runs to completion before any loading is performed.

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

### load

```
final suspend fun load(loadType: LoadType, state: PagingState<Key, Value>): RemoteMediator.MediatorResult
```

### loadSingle

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

```
abstract fun loadSingle(loadType: LoadType, state: PagingState<Key, Value>): Single<RemoteMediator.MediatorResult>
```

Implement this method to load additional remote data, which will then be stored for the `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` to access. These loads take one of two forms: \* type == `https://developer.android.com/reference/kotlin/androidx/paging/LoadType#PREPEND` / `https://developer.android.com/reference/kotlin/androidx/paging/LoadType#APPEND` The `https://developer.android.com/reference/kotlin/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/kotlin/androidx/paging/LoadType#REFRESH` The app (or `https://developer.android.com/reference/kotlin/androidx/paging/rxjava2/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/kotlin/androidx/paging/LoadState` callbacks registered to `https://developer.android.com/reference/kotlin/androidx/paging/PagingDataAdapter`.

NOTE: A `https://developer.android.com/reference/kotlin/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/kotlin/androidx/paging/LoadType#PREPEND` or `https://developer.android.com/reference/kotlin/androidx/paging/LoadType#APPEND` or both. `https://developer.android.com/reference/kotlin/androidx/paging/LoadType#REFRESH` occurs as a result of `https://developer.android.com/reference/kotlin/androidx/paging/rxjava2/RxRemoteMediator#initialize()`.

| Parameters |
|---|---|
| `loadType: https://developer.android.com/reference/kotlin/androidx/paging/LoadType` | `https://developer.android.com/reference/kotlin/androidx/paging/LoadType` of the boundary condition which triggered this callback. \* `https://developer.android.com/reference/kotlin/androidx/paging/LoadType#PREPEND` indicates a boundary condition at the front of the list. \* `https://developer.android.com/reference/kotlin/androidx/paging/LoadType#APPEND` indicates a boundary condition at the end of the list. \* `https://developer.android.com/reference/kotlin/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/kotlin/androidx/paging/rxjava2/RxRemoteMediator#initialize()`. |
| `state: https://developer.android.com/reference/kotlin/androidx/paging/PagingState<Key, Value>` | A copy of the state including the list of pages currently held in memory of the currently presented `https://developer.android.com/reference/kotlin/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://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Single.html<https://developer.android.com/reference/kotlin/androidx/paging/RemoteMediator.MediatorResult>` | `https://developer.android.com/reference/kotlin/androidx/paging/RemoteMediator.MediatorResult` signifying what `https://developer.android.com/reference/kotlin/androidx/paging/LoadState` to be passed to the UI, and whether there's more data available. |