Subscriber
SafeSubscriber is a wrapper around Subscriber that ensures that the Subscriber
complies with the Observable contract.
The following is taken from the Rx Design Guidelines document:
Messages sent to instances of the
IObserverinterface follow the following grammar:
OnNext* (OnCompleted | OnError)?This grammar allows observable sequences to send any amount (0 or more) of
OnNextmessages to the subscriber, optionally followed by a single success (OnCompleted) or failure (OnError) message.The single message indicating that an observable sequence has finished ensures that consumers of the observable sequence can deterministically establish that it is safe to perform cleanup operations.
A single failure further ensures that abort semantics can be maintained for operators that work on multiple observable sequences (see paragraph 6.6).
This wrapper does the following:
onError or onCompleted.onCompleted or onError is performed, no further calls can be executedunsubscribe is called, the upstream Observable is notified and the event delivery will be stopped in a
best effort manner (i.e., further onXXX calls may still slip through).onError or onCompleted occur, unsubscribes from the Observable (if executing asynchronously).SafeSubscriber will not synchronize onNext execution. Use SerializedSubscriber to do
that.
| Modifier and Type | Field and Description |
|---|---|
| private final Subscriber | |
| pack-priv boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected void | |
| public Subscriber | |
| public void | onCompleted()
Implements rx. Observable has finished sending push-based notifications.
|
| public void | onError(Throwable
the exception encountered by the Observable e)Implements rx. Observable has experienced an error condition.
|
| public void | onNext(T
the item emitted by the Observable t)Implements rx. |
| actual | back to summary |
|---|---|
| private final Subscriber<? super T> actual | |
| done | back to summary |
|---|---|
| pack-priv boolean done | |
| SafeSubscriber | back to summary |
|---|---|
| public SafeSubscriber(Subscriber<? super T> actual) | |
| _onError | back to summary |
|---|---|
| protected void _onError(Throwable e) The logic for
| |
| getActual | back to summary |
|---|---|
| public Subscriber Returns the
| |
| onCompleted | back to summary |
|---|---|
| public void onCompleted() Implements rx. Notifies the Subscriber that the
The
| |
| onError | back to summary |
|---|---|
| public void onError(Throwable e) Implements rx. Notifies the Subscriber that the
If the | |
| onNext | back to summary |
|---|---|
| public void onNext(T t) Implements rx. Provides the Subscriber with a new item to observe.
The
The
| |