Class SerializedSubscriber<T>
java.lang.Object
io.reactivex.rxjava4.subscribers.SerializedSubscriber<T>
- Type Parameters:
T- the value type
- All Implemented Interfaces:
FlowableSubscriber<T>, Flow.Subscriber<T>, Flow.Subscription
public final class SerializedSubscriber<T>
extends Object
implements FlowableSubscriber<T>, Flow.Subscription
Serializes access to the
Flow.Subscriber.onNext(Object), Flow.Subscriber.onError(Throwable) and
Flow.Subscriber.onComplete() methods of another Flow.Subscriber.
Note that onSubscribe(Subscription) is not serialized in respect of the other methods so
make sure the onSubscribe is called with a non-null Flow.Subscription
before any of the other methods are called.
The implementation assumes that the actual Subscriber's methods don't throw.
-
Constructor Summary
ConstructorsConstructorDescriptionSerializedSubscriber(@NonNull Flow.Subscriber<? super T> actual, boolean delayError) Construct aSerializedSubscriberby wrapping the given actualFlow.Subscriberand optionally delaying the errors till all regular values have been emitted from the internal buffer.SerializedSubscriber(Flow.Subscriber<? super T> downstream) Construct aSerializedSubscriberby wrapping the given actualFlow.Subscriber. -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()voidvoidvoidvoidImplementors of this method should make sure everything that needs to be visible inFlow.Subscriber.onNext(Object)is established before callingFlow.Subscription.request(long).voidrequest(long n)
-
Constructor Details
-
SerializedSubscriber
Construct aSerializedSubscriberby wrapping the given actualFlow.Subscriber.- Parameters:
downstream- the actualSubscriber, not null (not verified)
-
SerializedSubscriber
public SerializedSubscriber(@NonNull @NonNull Flow.Subscriber<? super T> actual, boolean delayError) Construct aSerializedSubscriberby wrapping the given actualFlow.Subscriberand optionally delaying the errors till all regular values have been emitted from the internal buffer.- Parameters:
actual- the actualSubscriber, notnull(not verified)delayError- iftrue, errors are emitted after regular values have been emitted
-
-
Method Details
-
onSubscribe
Description copied from interface:FlowableSubscriberImplementors of this method should make sure everything that needs to be visible inFlow.Subscriber.onNext(Object)is established before callingFlow.Subscription.request(long). In practice this means no initialization should happen after therequest()call and additional behavior is thread safe in respect toonNext.- Specified by:
onSubscribein interfaceFlow.Subscriber<T>- Specified by:
onSubscribein interfaceFlowableSubscriber<T>
-
onNext
- Specified by:
onNextin interfaceFlow.Subscriber<T>
-
onError
- Specified by:
onErrorin interfaceFlow.Subscriber<T>
-
onComplete
public void onComplete()- Specified by:
onCompletein interfaceFlow.Subscriber<T>
-
request
public void request(long n) - Specified by:
requestin interfaceFlow.Subscription
-
cancel
public void cancel()- Specified by:
cancelin interfaceFlow.Subscription
-