Class SafeSubscriber<T>

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 Details

    • SafeSubscriber

      public SafeSubscriber(Flow.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 Details

    • onSubscribe

      public void onSubscribe(Flow.Subscription subscription)
      Specified by:
      onSubscribe in interface Flow.Subscriber<T>
    • onNext

      public void onNext(T t)
      Specified by:
      onNext in interface Flow.Subscriber<T>
    • onError

      public void onError(Throwable t)
      Specified by:
      onError in interface Flow.Subscriber<T>
    • onComplete

      public void onComplete()
      Specified by:
      onComplete in interface Flow.Subscriber<T>
    • request

      public void request(long n)
      Specified by:
      request in interface Flow.Subscription
    • cancel

      public void cancel()
      Specified by:
      cancel in interface Flow.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 interface ContextSupport
      Returns:
      the context, must not be null.