Class 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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 interface org.reactivestreams.Subscriber<T>
      • onNext

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

        public void onError​(java.lang.Throwable t)
        Specified by:
        onError in interface org.reactivestreams.Subscriber<T>
      • onComplete

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

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

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