Class SerializedSubscriber<T>

  • Type Parameters:
    T - the type of items expected to be emitted to the Subscriber
    All Implemented Interfaces:
    Observer<T>, Subscription


    public class SerializedSubscriber<T>
    extends Subscriber<T>
    Enforces single-threaded, serialized, ordered execution of onNext(T), onCompleted(), and onError(java.lang.Throwable).

    When multiple threads are emitting and/or notifying they will be serialized by:

    • Allowing only one thread at a time to emit
    • Adding notifications to a queue if another thread is already emitting
    • Not holding any locks or blocking any threads while emitting
    • Constructor Detail

      • SerializedSubscriber

        public SerializedSubscriber(Subscriber<? super T> s)
    • Method Detail

      • onCompleted

        public void onCompleted()
        Notifies the Subscriber that the Observable has finished sending push-based notifications.

        The Observable will not call this method if it calls onError(java.lang.Throwable).

      • onError

        public void onError(Throwable e)
        Notifies the Subscriber that the Observable has experienced an error condition.

        If the Observable calls this method, it will not thereafter call onNext(T) or onCompleted().

        Parameters:
        e - the exception encountered by the Observable
      • onNext

        public void onNext(T t)
        Provides the Subscriber with a new item to observe.

        The Observable may call this method 0 or more times.

        The Observable will not call this method again after it calls either onCompleted() or onError(java.lang.Throwable).

        Parameters:
        t - the item emitted by the Observable