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 java.lang.Object implements Observer<T>
Observer wrapping the actual Subscriber and providing various emission facilities.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Subscriber<? super T>actualThe actual Observer.(package private) booleancaughtUpIndicate that the observer has caught up.(package private) booleanemittingGuarded by this.(package private) booleanfastPath(package private) booleanfirstWas the emitFirst run? Guarded by this.private java.lang.ObjectindexIndicate where the observer is at replaying.(package private) java.util.List<java.lang.Object>queueGuarded by this.
-
Constructor Summary
Constructors Constructor Description SubjectObserver(Subscriber<? super T> actual)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidaccept(java.lang.Object n, NotificationLite<T> nl)Dispatches a NotificationLite value to the actual Observer.(package private) voidemitFirst(java.lang.Object n, NotificationLite<T> nl)Tries to emit a NotificationLite value as the first value and drains the queue as long as possible.(package private) voidemitLoop(java.util.List<java.lang.Object> localQueue, java.lang.Object current, NotificationLite<T> nl)Emits the contents of the queue as long as there are values.(package private) voidemitNext(java.lang.Object n, NotificationLite<T> nl)Emits the given NotificationLite value and prevents the emitFirst to run if not already run.(package private) Observer<? super T>getActual()<I> Iindex()Returns the stored index.voidindex(java.lang.Object newIndex)Sets a new index value.voidonCompleted()Notifies the Observer that theObservablehas finished sending push-based notifications.voidonError(java.lang.Throwable e)Notifies the Observer that theObservablehas experienced an error condition.voidonNext(T t)Provides the Observer with a new item to observe.
-
-
-
Field Detail
-
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
java.util.List<java.lang.Object> queue
Guarded by this.
-
fastPath
boolean fastPath
-
caughtUp
volatile boolean caughtUp
Indicate that the observer has caught up.
-
index
private volatile java.lang.Object index
Indicate where the observer is at replaying.
-
-
Constructor Detail
-
SubjectObserver
public SubjectObserver(Subscriber<? super T> actual)
-
-
Method Detail
-
onNext
public void onNext(T t)
Description copied from interface:ObserverProvides the Observer with a new item to observe.The
Observablemay call this method 0 or more times.The
Observablewill not call this method again after it calls eitherObserver.onCompleted()orObserver.onError(java.lang.Throwable).
-
onError
public void onError(java.lang.Throwable e)
Description copied from interface:ObserverNotifies the Observer that theObservablehas experienced an error condition.If the
Observablecalls this method, it will not thereafter callObserver.onNext(T)orObserver.onCompleted().
-
onCompleted
public void onCompleted()
Description copied from interface:ObserverNotifies the Observer that theObservablehas finished sending push-based notifications.The
Observablewill not call this method if it callsObserver.onError(java.lang.Throwable).- Specified by:
onCompletedin interfaceObserver<T>
-
emitNext
void emitNext(java.lang.Object n, NotificationLite<T> nl)Emits the given NotificationLite value and prevents the emitFirst to run if not already run.- Parameters:
n- the NotificationLite valuenl- the type-appropriate notification lite object
-
emitFirst
void emitFirst(java.lang.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 valuenl- the type-appropriate notification lite object
-
emitLoop
void emitLoop(java.util.List<java.lang.Object> localQueue, java.lang.Object current, NotificationLite<T> nl)Emits the contents of the queue as long as there are values.- Parameters:
localQueue- the initial queue contentscurrent- the current content to emitnl- the type-appropriate notification lite object
-
accept
void accept(java.lang.Object n, NotificationLite<T> nl)Dispatches a NotificationLite value to the actual Observer.- Parameters:
n- the value to dispatchnl- the type-appropriate notification lite object
-
index
public <I> I index()
Returns the stored index.- Type Parameters:
I- the index type- Returns:
- the index value
-
index
public void index(java.lang.Object newIndex)
Sets a new index value.- Parameters:
newIndex- the new index value
-
-