Package rx.subjects

Class SubjectSubscriptionManager.SubjectObserver<T>

java.lang.Object
rx.subjects.SubjectSubscriptionManager.SubjectObserver<T>
Type Parameters:
T - the consumed value type of the actual Observer
All Implemented Interfaces:
Observer<T>
Enclosing class:
SubjectSubscriptionManager<T>

protected static final class SubjectSubscriptionManager.SubjectObserver<T> extends Object implements Observer<T>
Observer wrapping the actual Subscriber and providing various emission facilities.
  • Field Details

    • actual

      final Subscriber<? super T> actual
      The actual Observer.
    • first

      boolean first
      Was the emitFirst run? Guarded by this.
    • emitting

      boolean emitting
      Guarded by this.
    • queue

      List<Object> queue
      Guarded by this.
    • fastPath

      boolean fastPath
    • caughtUp

      volatile boolean caughtUp
      Indicate that the observer has caught up.
    • index

      private volatile Object index
      Indicate where the observer is at replaying.
  • Constructor Details

    • SubjectObserver

      public SubjectObserver(Subscriber<? super T> actual)
  • Method Details

    • onNext

      public void onNext(T t)
      Description copied from interface: Observer
      Provides the Observer 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 Observer.onCompleted() or Observer.onError(java.lang.Throwable).

      Specified by:
      onNext in interface Observer<T>
      Parameters:
      t - the item emitted by the Observable
    • onError

      public void onError(Throwable e)
      Description copied from interface: Observer
      Notifies the Observer that the Observable has experienced an error condition.

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

      Specified by:
      onError in interface Observer<T>
      Parameters:
      e - the exception encountered by the Observable
    • onCompleted

      public void onCompleted()
      Description copied from interface: Observer
      Notifies the Observer that the Observable has finished sending push-based notifications.

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

      Specified by:
      onCompleted in interface Observer<T>
    • emitNext

      void emitNext(Object n, NotificationLite<T> nl)
      Emits the given NotificationLite value and prevents the emitFirst to run if not already run.
      Parameters:
      n - the NotificationLite value
      nl - the type-appropriate notification lite object
    • emitFirst

      void emitFirst(Object n, NotificationLite<T> nl)
      Tries to emit a NotificationLite value as the first value and drains the queue as long as possible.
      Parameters:
      n - the NotificationLite value
      nl - the type-appropriate notification lite object
    • emitLoop

      void emitLoop(List<Object> localQueue, Object current, NotificationLite<T> nl)
      Emits the contents of the queue as long as there are values.
      Parameters:
      localQueue - the initial queue contents
      current - the current content to emit
      nl - the type-appropriate notification lite object
    • accept

      void accept(Object n, NotificationLite<T> nl)
      Dispatches a NotificationLite value to the actual Observer.
      Parameters:
      n - the value to dispatch
      nl - the type-appropriate notification lite object
    • getActual

      Observer<? super T> getActual()
      Returns:
      the actual Observer.
    • index

      public <I> I index()
      Returns the stored index.
      Type Parameters:
      I - the index type
      Returns:
      the index value
    • index

      public void index(Object newIndex)
      Sets a new index value.
      Parameters:
      newIndex - the new index value