Class AsyncSubject<T>

  • Type Parameters:
    T - the type of item expected to be observed by the Subject
    All Implemented Interfaces:
    Observer<T>


    public final class AsyncSubject<T>
    extends Subject<T,T>
    Subject that publishes only the last item observed to each Observer that has subscribed, when the source Observable completes.

    Example usage:

      // observer will receive no onNext events because the subject.onCompleted() isn't called. AsyncSubject<Object> subject = AsyncSubject.create(); subject.subscribe(observer); subject.onNext("one"); subject.onNext("two"); subject.onNext("three"); // observer will receive "three" as the only onNext event. AsyncSubject<Object> subject = AsyncSubject.create(); subject.subscribe(observer); subject.onNext("one"); subject.onNext("two"); subject.onNext("three"); subject.onCompleted();  
    • Constructor Detail

      • AsyncSubject

        protected AsyncSubject(Observable.OnSubscribe<T> onSubscribe,
                               rx.subjects.SubjectSubscriptionManager<T> state)
    • Method Detail

      • create

        public static <T> AsyncSubject<T> create()
        Creates and returns a new AsyncSubject.
        Type Parameters:
        T - the result value type
        Returns:
        the new AsyncSubject
      • hasObservers

        public boolean hasObservers()
        Description copied from class: Subject
        Indicates whether the Subject has Observers subscribed to it.
        Specified by:
        hasObservers in class  Subject<T,T>
        Returns:
        true if there is at least one Observer subscribed to this Subject, false otherwise