public final class ReplayingShare<T>
extends java.lang.Object
implements io.reactivex.rxjava3.core.ObservableTransformer<T,T>, io.reactivex.rxjava3.core.FlowableTransformer<T,T>
replay(1), publish(), and refCount()
operators.
Unlike traditional combinations of these operators, `ReplayingShare` caches the last emitted value from the upstream observable or flowable *only* when one or more downstream subscribers are connected. This allows expensive upstream sources to be shut down when no one is listening while also replaying the last value seen by *any* subscriber to new ones.
| Modifier and Type | Method and Description |
|---|---|
io.reactivex.rxjava3.core.Flowable<T> |
apply(io.reactivex.rxjava3.core.Flowable<T> upstream) |
io.reactivex.rxjava3.core.Observable<T> |
apply(io.reactivex.rxjava3.core.Observable<T> upstream) |
static <T> @NonNull ReplayingShare<T> |
createWithDefault(T defaultValue)
Creates a `ReplayingShare` transformer with a default value which will be emitted downstream
on subscription if there is not any cached value yet.
|
static <T> @NonNull ReplayingShare<T> |
instance()
The singleton instance of this transformer.
|
@NonNull public static <T> @NonNull ReplayingShare<T> instance()
@NonNull public static <T> @NonNull ReplayingShare<T> createWithDefault(@NonNull T defaultValue)
defaultValue - the initial value delivered to new subscribers before any events are
cached.public io.reactivex.rxjava3.core.Observable<T> apply(io.reactivex.rxjava3.core.Observable<T> upstream)
Copyright © 2016-2020. All Rights Reserved.