# PagingRx

Added in 3.0.0

*** ** * ** ***


```
public final class PagingRx
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingData<@https://developer.android.com/reference/androidx/annotation/NonNull T>>` | `@https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-experimental-coroutines-api/index.html <T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/paging/rxjava3/PagingRx#(io.reactivex.rxjava3.core.Flowable).cachedIn(kotlinx.coroutines.CoroutineScope)( @https://developer.android.com/reference/androidx/annotation/NonNull http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingData<@https://developer.android.com/reference/androidx/annotation/NonNull T>> receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html scope )` Operator which caches a `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html` of `https://developer.android.com/reference/androidx/paging/PagingData` within a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Observable.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingData<@https://developer.android.com/reference/androidx/annotation/NonNull T>>` | `@https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-experimental-coroutines-api/index.html <T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/paging/rxjava3/PagingRx#(io.reactivex.rxjava3.core.Observable).cachedIn(kotlinx.coroutines.CoroutineScope)( @https://developer.android.com/reference/androidx/annotation/NonNull http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Observable.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingData<@https://developer.android.com/reference/androidx/annotation/NonNull T>> receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html scope )` Operator which caches an `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Observable.html` of `https://developer.android.com/reference/androidx/paging/PagingData` within a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingData<@https://developer.android.com/reference/androidx/annotation/NonNull T>` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/paging/rxjava3/PagingRx#(androidx.paging.PagingData).filter(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingData<@https://developer.android.com/reference/androidx/annotation/NonNull T> receiver, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull T, @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/java/lang/Boolean.html>> predicate )` Returns a `https://developer.android.com/reference/androidx/paging/PagingData` containing only elements matching the given `https://developer.android.com/reference/androidx/paging/rxjava3/package-summary#(androidx.paging.PagingData).filterAsync(kotlin.Function1)`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingData<@https://developer.android.com/reference/androidx/annotation/NonNull R>` | `<T extends https://developer.android.com/reference/java/lang/Object.html, R extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/paging/rxjava3/PagingRx#(androidx.paging.PagingData).flatMap(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingData<@https://developer.android.com/reference/androidx/annotation/NonNull T> receiver, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull T, @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/java/lang/Iterable.html<@https://developer.android.com/reference/androidx/annotation/NonNull R>>> transform )` Returns a `https://developer.android.com/reference/androidx/paging/PagingData` of all elements returned from applying the given `https://developer.android.com/reference/androidx/paging/rxjava3/package-summary#(androidx.paging.PagingData).flatMapAsync(kotlin.Function1)` to each element, as it is loaded. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingData<@https://developer.android.com/reference/androidx/annotation/NonNull Value>>` | `<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/PagingRx#(androidx.paging.Pager).getFlowable()( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/Pager<@https://developer.android.com/reference/androidx/annotation/NonNull Key, @https://developer.android.com/reference/androidx/annotation/NonNull Value> receiver )` A `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html` of `https://developer.android.com/reference/androidx/paging/PagingData`, which mirrors the stream provided by `https://developer.android.com/reference/androidx/paging/Pager#flow()`, but exposes it as a `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Observable.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingData<@https://developer.android.com/reference/androidx/annotation/NonNull Value>>` | `<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/PagingRx#(androidx.paging.Pager).getObservable()( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/Pager<@https://developer.android.com/reference/androidx/annotation/NonNull Key, @https://developer.android.com/reference/androidx/annotation/NonNull Value> receiver )` An `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Observable.html` of `https://developer.android.com/reference/androidx/paging/PagingData`, which mirrors the stream provided by `https://developer.android.com/reference/androidx/paging/Pager#flow()`, but exposes it as an `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Observable.html`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingData<@https://developer.android.com/reference/androidx/annotation/NonNull R>` | `<T extends R, R extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/paging/rxjava3/PagingRx#(androidx.paging.PagingData).insertSeparators(kotlin.Function2)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingData<@https://developer.android.com/reference/androidx/annotation/NonNull T> receiver, @https://developer.android.com/reference/androidx/annotation/NonNull Function2<T, T, @https://developer.android.com/reference/androidx/annotation/NonNull http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Maybe.html<@https://developer.android.com/reference/androidx/annotation/NonNull R>> generator )` Returns a `https://developer.android.com/reference/androidx/paging/PagingData` containing each original element, with an optional separator generated by `https://developer.android.com/reference/androidx/paging/rxjava3/package-summary#(androidx.paging.PagingData).insertSeparatorsAsync(kotlin.Function2)`, given the elements before and after (or null, in boundary conditions). |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingData<@https://developer.android.com/reference/androidx/annotation/NonNull R>` | `<T extends https://developer.android.com/reference/java/lang/Object.html, R extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/paging/rxjava3/PagingRx#(androidx.paging.PagingData).map(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingData<@https://developer.android.com/reference/androidx/annotation/NonNull T> receiver, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull T, @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 R>> transform )` Returns a `https://developer.android.com/reference/androidx/paging/PagingData` containing the result of applying the given `https://developer.android.com/reference/androidx/paging/rxjava3/package-summary#(androidx.paging.PagingData).mapAsync(kotlin.Function1)` to each element, as it is loaded. |

## Public methods

### cachedIn

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/PagingRx.kt+function:cachedIn) Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

```
@ExperimentalCoroutinesApi
public static final @NonNull Flowable<@NonNull PagingData<@NonNull T>> <T extends Object> cachedIn(
    @NonNull Flowable<@NonNull PagingData<@NonNull T>> receiver,
    @NonNull CoroutineScope scope
)
```

Operator which caches a `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html` of `https://developer.android.com/reference/androidx/paging/PagingData` within a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html`.

`https://developer.android.com/reference/androidx/paging/rxjava3/package-summary#(io.reactivex.rxjava3.core.Flowable).cachedIn(kotlinx.coroutines.CoroutineScope)` multicasts pages loaded and transformed by a `https://developer.android.com/reference/androidx/paging/PagingData`, allowing multiple observers on the same instance of `https://developer.android.com/reference/androidx/paging/PagingData` to receive the same events, avoiding redundant work, but comes at the cost of buffering those pages in memory.

Calling `https://developer.android.com/reference/androidx/paging/rxjava3/package-summary#(io.reactivex.rxjava3.core.Flowable).cachedIn(kotlinx.coroutines.CoroutineScope)` is required to allow calling androidx.paging.AsyncPagingDataAdapter on the same instance of `https://developer.android.com/reference/androidx/paging/PagingData` emitted by `https://developer.android.com/reference/androidx/paging/Pager` or any of its transformed derivatives, as reloading data from scratch on the same generation of `https://developer.android.com/reference/androidx/paging/PagingData` is an unsupported operation.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html scope` | The `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html` where the page cache will be kept alive. Typically this would be a managed scope such as `ViewModel.viewModelScope`, which automatically cancels after the `https://developer.android.com/reference/androidx/paging/PagingData` stream is no longer needed. Otherwise, the provided `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html` must be manually cancelled to avoid memory leaks. |

### cachedIn

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/PagingRx.kt+function:cachedIn) Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

```
@ExperimentalCoroutinesApi
public static final @NonNull Observable<@NonNull PagingData<@NonNull T>> <T extends Object> cachedIn(
    @NonNull Observable<@NonNull PagingData<@NonNull T>> receiver,
    @NonNull CoroutineScope scope
)
```

Operator which caches an `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Observable.html` of `https://developer.android.com/reference/androidx/paging/PagingData` within a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html`.

`https://developer.android.com/reference/androidx/paging/rxjava3/package-summary#(io.reactivex.rxjava3.core.Observable).cachedIn(kotlinx.coroutines.CoroutineScope)` multicasts pages loaded and transformed by a `https://developer.android.com/reference/androidx/paging/PagingData`, allowing multiple observers on the same instance of `https://developer.android.com/reference/androidx/paging/PagingData` to receive the same events, avoiding redundant work, but comes at the cost of buffering those pages in memory.

Calling `https://developer.android.com/reference/androidx/paging/rxjava3/package-summary#(io.reactivex.rxjava3.core.Observable).cachedIn(kotlinx.coroutines.CoroutineScope)` is required to allow calling androidx.paging.AsyncPagingDataAdapter on the same instance of `https://developer.android.com/reference/androidx/paging/PagingData` emitted by `https://developer.android.com/reference/androidx/paging/Pager` or any of its transformed derivatives, as reloading data from scratch on the same generation of `https://developer.android.com/reference/androidx/paging/PagingData` is an unsupported operation.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html scope` | The `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html` where the page cache will be kept alive. Typically this would be a managed scope such as `ViewModel.viewModelScope`, which automatically cancels after the `https://developer.android.com/reference/androidx/paging/PagingData` stream is no longer needed. Otherwise, the provided `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html` must be manually cancelled to avoid memory leaks. |

### filter

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/RxPagingData.kt+function:filterAsync) Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

```
public static final @NonNull PagingData<@NonNull T> <T extends Object> filter(
    @NonNull PagingData<@NonNull T> receiver,
    @NonNull Function1<@NonNull T, @NonNull Single<@NonNull Boolean>> predicate
)
```

Returns a `https://developer.android.com/reference/androidx/paging/PagingData` containing only elements matching the given `https://developer.android.com/reference/androidx/paging/rxjava3/package-summary#(androidx.paging.PagingData).filterAsync(kotlin.Function1)`.

### flatMap

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/RxPagingData.kt+function:flatMapAsync) Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

```
public static final @NonNull PagingData<@NonNull R> <T extends Object, R extends Object> flatMap(
    @NonNull PagingData<@NonNull T> receiver,
    @NonNull Function1<@NonNull T, @NonNull Single<@NonNull Iterable<@NonNull R>>> transform
)
```

Returns a `https://developer.android.com/reference/androidx/paging/PagingData` of all elements returned from applying the given `https://developer.android.com/reference/androidx/paging/rxjava3/package-summary#(androidx.paging.PagingData).flatMapAsync(kotlin.Function1)` to each element, as it is loaded.

### getFlowable

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/PagingRx.kt+symbol:flowable) Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

```
public static final @NonNull Flowable<@NonNull PagingData<@NonNull Value>> <Key extends Object, Value extends Object> getFlowable(
    @NonNull Pager<@NonNull Key, @NonNull Value> receiver
)
```

A `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html` of `https://developer.android.com/reference/androidx/paging/PagingData`, which mirrors the stream provided by `https://developer.android.com/reference/androidx/paging/Pager#flow()`, but exposes it as a `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html`.

NOTE: Instances of `https://developer.android.com/reference/androidx/paging/PagingData` emitted by this `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html` are not re-usable and cannot be submitted multiple times. This is especially relevant for transforms, which would replay the latest value downstream. To ensure you get a new instance of `https://developer.android.com/reference/androidx/paging/PagingData` for each downstream observer, you should use the `https://developer.android.com/reference/androidx/paging/package-summary#(androidx.lifecycle.LiveData).cachedIn(androidx.lifecycle.Lifecycle)` operator which multicasts the `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html` in a way that returns a new instance of `https://developer.android.com/reference/androidx/paging/PagingData` with cached data pre-loaded.

### getObservable

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/PagingRx.kt+symbol:observable) Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

```
public static final @NonNull Observable<@NonNull PagingData<@NonNull Value>> <Key extends Object, Value extends Object> getObservable(
    @NonNull Pager<@NonNull Key, @NonNull Value> receiver
)
```

An `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Observable.html` of `https://developer.android.com/reference/androidx/paging/PagingData`, which mirrors the stream provided by `https://developer.android.com/reference/androidx/paging/Pager#flow()`, but exposes it as an `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Observable.html`.

NOTE: Instances of `https://developer.android.com/reference/androidx/paging/PagingData` emitted by this `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Observable.html` are not re-usable and cannot be submitted multiple times. This is especially relevant for transforms, which would replay the latest value downstream. To ensure you get a new instance of `https://developer.android.com/reference/androidx/paging/PagingData` for each downstream observer, you should use the `https://developer.android.com/reference/androidx/paging/package-summary#(androidx.lifecycle.LiveData).cachedIn(androidx.lifecycle.Lifecycle)` operator which multicasts the `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Observable.html` in a way that returns a new instance of `https://developer.android.com/reference/androidx/paging/PagingData` with cached data pre-loaded.

### insertSeparators

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/RxPagingData.kt+function:insertSeparatorsAsync) Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

```
public static final @NonNull PagingData<@NonNull R> <T extends R, R extends Object> insertSeparators(
    @NonNull PagingData<@NonNull T> receiver,
    @NonNull Function2<T, T, @NonNull Maybe<@NonNull R>> generator
)
```

Returns a `https://developer.android.com/reference/androidx/paging/PagingData` containing each original element, with an optional separator generated by `https://developer.android.com/reference/androidx/paging/rxjava3/package-summary#(androidx.paging.PagingData).insertSeparatorsAsync(kotlin.Function2)`, given the elements before and after (or null, in boundary conditions).

Note that this transform is applied asynchronously, as pages are loaded. Potential separators between pages are only computed once both pages are loaded.

```kotlin
import androidx.paging.insertSeparators
import androidx.paging.insertSeparatorsAsync
import androidx.paging.rxjava2.insertSeparatorsAsync

/*
 * Create letter separators in an alphabetically sorted list.
 *
 * For example, if the input is:
 *     "apple", "apricot", "banana", "carrot"
 *
 * The operator would output:
 *     "A", "apple", "apricot", "B", "banana", "C", "carrot"
 */
pagingDataStream.map { pagingData ->
    // map outer stream, so we can perform transformations on each paging generation
    pagingData.insertSeparatorsAsync { before: String?, after: String? ->
        Maybe.fromCallable<String> {
                if (after != null && before?.first() != after.first()) {
                    // separator - after is first item that starts with its first letter
                    after.first().uppercaseChar().toString()
                } else {
                    // no separator - either end of list, or first letters of before/after are
                    // the same
                    null
                }
            }
            .subscribeOn(Schedulers.computation())
    }
}
```

```kotlin
import androidx.paging.insertSeparators
import androidx.paging.insertSeparatorsAsync
import androidx.paging.map
import androidx.paging.rxjava2.insertSeparatorsAsync

open class UiModel
data class ItemUiModel(val item: Item) : UiModel()
data class SeparatorUiModel(val char: Char) : UiModel()

/*
 * Create letter separators in an alphabetically sorted list of Items, with UiModel objects.
 *
 * For example, if the input is (each an `Item`):
 *     "apple", "apricot", "banana", "carrot"
 *
 * The operator would output a list of UiModels corresponding to:
 *     "A", "apple", "apricot", "B", "banana", "C", "carrot"
 */
pagingDataStream.map { pagingData ->
    // map outer stream, so we can perform transformations on each paging generation
    pagingData
        .map { item ->
            ItemUiModel(item) // convert items in stream to ItemUiModel
        }
        .insertSeparatorsAsync { before: ItemUiModel?, after: ItemUiModel? ->
            Maybe.fromCallable<UiModel> {
                    if (
                        after != null &&
                            before?.item?.label?.first() != after.item.label.first()
                    ) {
                        // separator - after is first item that starts with its first letter
                        SeparatorUiModel(after.item.label.first().uppercaseChar())
                    } else {
                        // no separator - either end of list, or first letters of before/after
                        // are the same
                        null
                    }
                }
                .subscribeOn(Schedulers.computation())
        }
}
```

### map

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/RxPagingData.kt+function:mapAsync) Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

```
public static final @NonNull PagingData<@NonNull R> <T extends Object, R extends Object> map(
    @NonNull PagingData<@NonNull T> receiver,
    @NonNull Function1<@NonNull T, @NonNull Single<@NonNull R>> transform
)
```

Returns a `https://developer.android.com/reference/androidx/paging/PagingData` containing the result of applying the given `https://developer.android.com/reference/androidx/paging/rxjava3/package-summary#(androidx.paging.PagingData).mapAsync(kotlin.Function1)` to each element, as it is loaded.