Package rx.observers
Class SerializedSubscriber<T>
- java.lang.Object
-
- rx.Subscriber<T>
-
- rx.observers.SerializedSubscriber<T>
-
- Type Parameters:
T- the type of items expected to be emitted to theSubscriber
- All Implemented Interfaces:
Observer<T>,Subscription
public class SerializedSubscriber<T> extends Subscriber<T>
Enforces single-threaded, serialized, ordered execution ofonNext(T),onCompleted(), andonError(java.lang.Throwable).When multiple threads are emitting and/or notifying they will be serialized by:
- Allowing only one thread at a time to emit
- Adding notifications to a queue if another thread is already emitting
- Not holding any locks or blocking any threads while emitting
-
-
Constructor Summary
Constructors Constructor Description SerializedSubscriber(Subscriber<? super T> s)SerializedSubscriber(Subscriber<? super T> s, boolean shareSubscriptions)Constructor for wrapping and serializing a subscriber optionally sharing the same underlying subscription list.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidonCompleted()Notifies the Subscriber that theObservablehas finished sending push-based notifications.voidonError(java.lang.Throwable e)Notifies the Subscriber that theObservablehas experienced an error condition.voidonNext(T t)Provides the Subscriber with a new item to observe.-
Methods inherited from class rx.Subscriber
add, isUnsubscribed, onStart, request, setProducer, unsubscribe
-
-
-
-
Constructor Detail
-
SerializedSubscriber
public SerializedSubscriber(Subscriber<? super T> s)
-
SerializedSubscriber
public SerializedSubscriber(Subscriber<? super T> s, boolean shareSubscriptions)
Constructor for wrapping and serializing a subscriber optionally sharing the same underlying subscription list.- Parameters:
s- the subscriber to wrap and serializeshareSubscriptions- iftrue, the same subscription list is shared between this subscriber ands.- Since:
- 1.0.7
-
-
Method Detail
-
onCompleted
public void onCompleted()
Notifies the Subscriber that theObservablehas finished sending push-based notifications.The
Observablewill not call this method if it callsonError(java.lang.Throwable).
-
onError
public void onError(java.lang.Throwable e)
Notifies the Subscriber that theObservablehas experienced an error condition.If the
Observablecalls this method, it will not thereafter callonNext(T)oronCompleted().- Parameters:
e- the exception encountered by the Observable
-
onNext
public void onNext(T t)
Provides the Subscriber 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 eitheronCompleted()oronError(java.lang.Throwable).- Parameters:
t- the item emitted by the Observable
-
-