Class DispatchWorkSubject<T>

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

    public final class DispatchWorkSubject<T>
    extends Subject<T>
    implements Disposable
    A Subject variant that queues up items and dispatches them asynchronously so that one of the currently subscribed Observers can pick it up one by one, otherwise* cache it until at least an Observer subscribes.
    Since:
    0.18.8
    • Method Detail

      • create

        public static <T> DispatchWorkSubject<T> create​(Scheduler scheduler)
        Create an empty DispatchWorkSubject instance with the given scheduler, default capacity hint (Flowable.bufferSize(), expected number of items cached until consumption) and delaying errors.
        Type Parameters:
        T - the input and output value type
        Parameters:
        scheduler - the scheduler to use for the Observers to be notified on
        Returns:
        the new DispatchWorkSubject instance
      • create

        public static <T> DispatchWorkSubject<T> create​(Scheduler scheduler,
                                                        int capacityHint)
        Create an empty DispatchWorkSubject instance with the given scheduler, capacity hint (expected number of items cached until consumption) and delaying errors.
        Type Parameters:
        T - the input and output value type
        Parameters:
        scheduler - the scheduler to use for the Observers to be notified on
        capacityHint - the expected number of items to be cached until consumption
        Returns:
        the new DispatchWorkSubject instance
      • create

        public static <T> DispatchWorkSubject<T> create​(Scheduler scheduler,
                                                        boolean delayErrors)
        Create an empty DispatchWorkSubject instance with the given scheduler, default capacity hint (Flowable.bufferSize(), expected number of items cached until consumption) and if an error should be delayed.
        Type Parameters:
        T - the input and output value type
        Parameters:
        scheduler - the scheduler to use for the Observers to be notified on
        delayErrors - if true, errors are delivered after items have been consumed
        Returns:
        the new DispatchWorkSubject instance
      • create

        public static <T> DispatchWorkSubject<T> create​(Scheduler scheduler,
                                                        int capacityHint,
                                                        boolean delayErrors)
        Create an empty DispatchWorkSubject instance with the given scheduler, capacity hint (expected number of items cached until consumption) and if an error should be delayed.
        Type Parameters:
        T - the input and output value type
        Parameters:
        scheduler - the scheduler to use for the Observers to be notified on
        capacityHint - the expected number of items to be cached until consumption
        delayErrors - if true, errors are delivered after items have been consumed
        Returns:
        the new DispatchWorkSubject 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>