PagingRx

public final class PagingRx


Summary

Public fields

final @NonNull Flowable<@NonNull PagingData<@NonNull Value>>

A Flowable of PagingData, which mirrors the stream provided by Pager.flow, but exposes it as a Flowable.

final @NonNull Observable<@NonNull PagingData<@NonNull Value>>

An Observable of PagingData, which mirrors the stream provided by Pager.flow, but exposes it as an Observable.

Public constructors

Public methods

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

Operator which caches an Observable of PagingData within a CoroutineScope.

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

Operator which caches a Flowable of PagingData within a CoroutineScope.

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

Returns a PagingData containing only elements matching the given predicate.

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

Returns a PagingData of all elements returned from applying the given transform to each element, as it is loaded.

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

Returns a PagingData containing each original element, with an optional separator generated by generator, given the elements before and after (or null, in boundary conditions).

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

Returns a PagingData containing the result of applying the given transform to each element, as it is loaded.

Public fields

flowable

public final @NonNull Flowable<@NonNull PagingData<@NonNull Value>> flowable

A Flowable of PagingData, which mirrors the stream provided by Pager.flow, but exposes it as a Flowable.

NOTE: Instances of PagingData emitted by this Flowable 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 PagingData for each downstream observer, you should use the cachedIn operator which multicasts the Flowable in a way that returns a new instance of PagingData with cached data pre-loaded.

observable

public final @NonNull Observable<@NonNull PagingData<@NonNull Value>> observable

An Observable of PagingData, which mirrors the stream provided by Pager.flow, but exposes it as an Observable.

NOTE: Instances of PagingData emitted by this Observable 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 PagingData for each downstream observer, you should use the cachedIn operator which multicasts the Observable in a way that returns a new instance of PagingData with cached data pre-loaded.

Public constructors

PagingRx

public final PagingRx()

Public methods

PagingRx.cachedIn

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

Operator which caches an Observable of PagingData within a CoroutineScope.

cachedIn multicasts pages loaded and transformed by a PagingData, allowing multiple observers on the same instance of PagingData to receive the same events, avoiding redundant work, but comes at the cost of buffering those pages in memory.

Calling cachedIn is required to allow calling androidx.paging.AsyncPagingDataAdapter on the same instance of PagingData emitted by