T - the type of item the SingleSubscriber expects to observe
@Beta public abstract class SingleSubscriber<T> extends Objectimplements Subscription
After a SingleSubscriber calls a Single's subscribe method, the Single calls the SingleSubscriber's onSuccess(T) and onError(java.lang.Throwable) methods to provide notifications. A well-behaved Single will call a SingleSubscriber's onSuccess(T) method exactly once or the SingleSubscriber's onError(java.lang.Throwable) method exactly once.
| Constructor and Description |
|---|
SingleSubscriber()
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(Subscription
Adds a
Subscription to this Subscriber's list of subscriptions if this list is not marked as unsubscribed.
|
boolean |
isUnsubscribed()
Indicates whether this Subscriber has unsubscribed from its list of subscriptions.
|
abstract void |
onError(Throwable
Notifies the SingleSubscriber that the
Single has experienced an error condition.
|
abstract void |
onSuccess(T value)
Notifies the SingleSubscriber with a single item and that the
Single has finished sending push-based notifications.
|
void |
unsubscribe()
Stops the receipt of notifications on the
Subscriber that was registered when this Subscription was received.
|
public abstract void onSuccess(T value)
Single has finished sending push-based notifications.
The Single will not call this method if it calls onError(java.lang.Throwable).
value - the item emitted by the Single
public abstract void onError(Throwableerror)
Single has experienced an error condition.
If the Single calls this method, it will not thereafter call onSuccess(T).
error - the exception encountered by the Single
public final void add(Subscriptions)
Subscription to this Subscriber's list of subscriptions if this list is not marked as unsubscribed. If the list
is marked as unsubscribed,
add will indicate this by explicitly unsubscribing the new
Subscription as well.
s - the
Subscription to add
public final void unsubscribe()
Subscription
Subscriber that was registered when this Subscription was received.
This allows unregistering an Subscriber before it has finished receiving all events (i.e. before onCompleted is called).
public final boolean isUnsubscribed()
isUnsubscribed in interface
Subscription
true if this Subscriber has unsubscribed from its subscriptions,
false otherwise