Package rx
Class SingleSubscriber<T>
- java.lang.Object
-
- rx.SingleSubscriber<T>
-
- Type Parameters:
T- the type of item the SingleSubscriber expects to observe
- All Implemented Interfaces:
Subscription
- Direct Known Subclasses:
OnSubscribeOnAssemblySingle.OnAssemblySingleSubscriber,SingleDoAfterTerminate.SingleDoAfterTerminateSubscriber,SingleOnSubscribeMap.MapSubscriber
@Beta public abstract class SingleSubscriber<T> extends java.lang.Object implements Subscription
Provides a mechanism for receiving push-based notifications.After a SingleSubscriber calls a
Single'ssubscribemethod, theSinglecalls the SingleSubscriber'sonSuccess(T)andonError(java.lang.Throwable)methods to provide notifications. A well-behavedSinglewill call a SingleSubscriber'sonSuccess(T)method exactly once or the SingleSubscriber'sonError(java.lang.Throwable)method exactly once.- Since:
- (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
- See Also:
- ReactiveX documentation: Observable
-
-
Field Summary
Fields Modifier and Type Field Description private SubscriptionListcs
-
Constructor Summary
Constructors Constructor Description SingleSubscriber()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidadd(Subscription s)Adds aSubscriptionto this Subscriber's list of subscriptions if this list is not marked as unsubscribed.booleanisUnsubscribed()Indicates whether this Subscriber has unsubscribed from its list of subscriptions.abstract voidonError(java.lang.Throwable error)Notifies the SingleSubscriber that theSinglehas experienced an error condition.abstract voidonSuccess(T value)Notifies the SingleSubscriber with a single item and that theSinglehas finished sending push-based notifications.voidunsubscribe()Stops the receipt of notifications on theSubscriberthat was registered when this Subscription was received.
-
-
-
Field Detail
-
cs
private final SubscriptionList cs
-
-
Method Detail
-
onSuccess
public abstract void onSuccess(T value)
Notifies the SingleSubscriber with a single item and that theSinglehas finished sending push-based notifications.The
Singlewill not call this method if it callsonError(java.lang.Throwable).- Parameters:
value- the item emitted by the Single
-
onError
public abstract void onError(java.lang.Throwable error)
Notifies the SingleSubscriber that theSinglehas experienced an error condition.If the
Singlecalls this method, it will not thereafter callonSuccess(T).- Parameters:
error- the exception encountered by the Single
-
add
public final void add(Subscription s)
Adds aSubscriptionto this Subscriber's list of subscriptions if this list is not marked as unsubscribed. If the list is marked as unsubscribed,addwill indicate this by explicitly unsubscribing the newSubscriptionas well.- Parameters:
s- theSubscriptionto add
-
unsubscribe
public final void unsubscribe()
Description copied from interface:SubscriptionStops the receipt of notifications on theSubscriberthat was registered when this Subscription was received.This allows unregistering an
Subscriberbefore it has finished receiving all events (i.e. before onCompleted is called).- Specified by:
unsubscribein interfaceSubscription
-
isUnsubscribed
public final boolean isUnsubscribed()
Indicates whether this Subscriber has unsubscribed from its list of subscriptions.- Specified by:
isUnsubscribedin interfaceSubscription- Returns:
trueif this Subscriber has unsubscribed from its subscriptions,falseotherwise
-
-