Package io.smallrye.mutiny.subscription
Class SafeSubscriber<T>
- java.lang.Object
-
- io.smallrye.mutiny.subscription.SafeSubscriber<T>
-
- Type Parameters:
T
- the value type
- All Implemented Interfaces:
ContextSupport
,org.reactivestreams.Subscriber<T>
,org.reactivestreams.Subscription
public final class SafeSubscriber<T> extends java.lang.Object implements org.reactivestreams.Subscriber<T>, org.reactivestreams.Subscription, ContextSupport
Wraps another Subscriber and ensures all onXXX methods conform the protocol (except the requirement for serialized access).
-
-
Constructor Summary
Constructors Constructor Description SafeSubscriber(org.reactivestreams.Subscriber<? super T> downstream)
Constructs a SafeSubscriber by wrapping the given actual Subscriber.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
Context
context()
Provide a context.void
onComplete()
void
onError(java.lang.Throwable t)
void
onNext(T t)
void
onSubscribe(org.reactivestreams.Subscription subscription)
void
request(long n)
-
-
-
Constructor Detail
-
SafeSubscriber
public SafeSubscriber(org.reactivestreams.Subscriber<? super T> downstream)
Constructs a SafeSubscriber by wrapping the given actual Subscriber.- Parameters:
downstream
- the actual Subscriber to wrap, not null (not validated)
-
-
Method Detail
-
onSubscribe
public void onSubscribe(org.reactivestreams.Subscription subscription)
- Specified by:
onSubscribe
in interfaceorg.reactivestreams.Subscriber<T>
-
onError
public void onError(java.lang.Throwable t)
- Specified by:
onError
in interfaceorg.reactivestreams.Subscriber<T>
-
onComplete
public void onComplete()
- Specified by:
onComplete
in interfaceorg.reactivestreams.Subscriber<T>
-
request
public void request(long n)
- Specified by:
request
in interfaceorg.reactivestreams.Subscription
-
cancel
public void cancel()
- Specified by:
cancel
in interfaceorg.reactivestreams.Subscription
-
context
public Context context()
Description copied from interface:ContextSupport
Provide a context.Since calls to this method shall only be triggered when a Mutiny pipeline uses a
withContext
operator, 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
withContext
operator.- Specified by:
context
in interfaceContextSupport
- Returns:
- the context, must not be
null
.
-
-