Class UnicastWorkSubject<T>

  • Type Parameters:
    T - the input and output value type
    All Implemented Interfaces:
    ObservableSource<T>, Observer<T>, Disposable

    public final class UnicastWorkSubject<T>
    extends Subject<T>
    implements Disposable
    A Subject that holds an unbounded queue of items and relays/replays it to a single Observer at a time, making sure that when the Observer disposes, any unconsumed items are available for the next Observer.

    This Subject doesn't allow more than one Observers at a time.

    The UnicastWorkSubject also allows disconnecting from the optional upstream via dispose().

    Since:
    0.18.8
    • Method Detail

      • create

        public static <T> UnicastWorkSubject<T> create​(int capacityHint)
        Constructs an empty UnicastWorkSubject with the given capacity hint (expected number of cached items) and error delaying behavior.
        Type Parameters:
        T - the input and output value type
        Parameters:
        capacityHint - the number of items expected to be cached, larger number reduces the internal allocation count if the consumer is slow
        Returns:
        the new UnicastWorkSubject instance
        See Also:
        create(int, boolean)
      • create

        public static <T> UnicastWorkSubject<T> create​(boolean delayErrors)
        Constructs an empty UnicastWorkSubject with the given capacity hint (expected number of cached items) of Flowable.bufferSize() and optional error delaying behavior.
        Type Parameters:
        T - the input and output value type
        Parameters:
        delayErrors - if true, errors are emitted last
        Returns:
        the new UnicastWorkSubject instance
        See Also:
        create(int, boolean)
      • create

        public static <T> UnicastWorkSubject<T> create​(int capacityHint,
                                                       boolean delayErrors)
        Constructs an empty UnicastWorkSubject with the given capacity hint (expected number of cached items) and optional error delaying behavior.
        Type Parameters:
        T - the input and output value type
        Parameters:
        capacityHint - the number of items expected to be cached, larger number reduces the internal allocation count if the consumer is slow
        delayErrors - if true, errors are emitted last
        Returns:
        the new UnicastWorkSubject instance
      • onNext

        public void onNext​(T t)
        Specified by:
        onNext in interface Observer<T>
      • onError

        public void onError​(java.lang.Throwable e)
        Specified by:
        onError in interface Observer<T>
      • getThrowable

        public java.lang.Throwable getThrowable()
        Specified by:
        getThrowable in class Subject<T>