java.lang.Object
io.smallrye.mutiny.subscription.SafeSubscriber<T>
- Type Parameters:
T- the value type
- All Implemented Interfaces:
ContextSupport,Flow.Subscriber<T>,Flow.Subscription
public final class SafeSubscriber<T>
extends Object
implements Flow.Subscriber<T>, Flow.Subscription, ContextSupport
Wraps another Subscriber and ensures all onXXX methods conform the protocol
(except the requirement for serialized access).
-
Constructor Summary
ConstructorsConstructorDescriptionSafeSubscriber(Flow.Subscriber<? super T> downstream) Constructs a SafeSubscriber by wrapping the given actual Subscriber. -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()context()Provide a context.voidvoidvoidvoidonSubscribe(Flow.Subscription subscription) voidrequest(long n)
-
Constructor Details
-
SafeSubscriber
Constructs a SafeSubscriber by wrapping the given actual Subscriber.- Parameters:
downstream- the actual Subscriber to wrap, not null (not validated)
-
-
Method Details
-
onSubscribe
- Specified by:
onSubscribein interfaceFlow.Subscriber<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
-
context
Description copied from interface:ContextSupportProvide a context.Since calls to this method shall only be triggered when a Mutiny pipeline uses a
withContextoperator, there is no need in general for caching the context value in a field of the implementing class. Exceptions include operators that have cross-subscriber semantics such as memoizers or broadcasters.This method is expected to be called once per
withContextoperator.- Specified by:
contextin interfaceContextSupport- Returns:
- the context, must not be
null.
-