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 Object implements Subscription
Provides a mechanism for receiving push-based notifications.

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.

Since:
(if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final SubscriptionList
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    Adds a Subscription to this Subscriber's list of subscriptions if this list is not marked as unsubscribed.
    final boolean
    Indicates whether this Subscriber has unsubscribed from its list of subscriptions.
    abstract void
    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.
    final void
    Stops the receipt of notifications on the Subscriber that was registered when this Subscription was received.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • SingleSubscriber

      public SingleSubscriber()
  • Method Details

    • onSuccess

      public abstract void onSuccess(T value)
      Notifies the SingleSubscriber with a single item and that the Single has finished sending push-based notifications.

      The Single will not call this method if it calls onError(java.lang.Throwable).

      Parameters:
      value - the item emitted by the Single
    • onError

      public abstract void onError(Throwable error)
      Notifies the SingleSubscriber that the Single has experienced an error condition.

      If the Single calls this method, it will not thereafter call onSuccess(T).

      Parameters:
      error - the exception encountered by the Single
    • add

      public final void add(Subscription s)
      Adds a 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.
      Parameters:
      s - the Subscription to add
    • unsubscribe

      public final void unsubscribe()
      Description copied from interface: Subscription
      Stops the receipt of notifications on the 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).

      Specified by:
      unsubscribe in interface Subscription
    • isUnsubscribed

      public final boolean isUnsubscribed()
      Indicates whether this Subscriber has unsubscribed from its list of subscriptions.
      Specified by:
      isUnsubscribed in interface Subscription
      Returns:
      true if this Subscriber has unsubscribed from its subscriptions, false otherwise