RxJava



rx.operators
Class SafeObservableSubscription

java.lang.Object
  extended by rx.operators.SafeObservableSubscription
All Implemented Interfaces:
Subscription

public final class SafeObservableSubscription
extends java.lang.Object
implements Subscription

Thread-safe wrapper around Observable Subscription that ensures unsubscribe can be called only once.

Also used to:


Constructor Summary
SafeObservableSubscription()
           
SafeObservableSubscription(Subscription actualSubscription)
           
 
Method Summary
 boolean isUnsubscribed()
           
 void unsubscribe()
          Stop receiving notifications on the Observer that was registered when this Subscription was received.
 SafeObservableSubscription wrap(Subscription actualSubscription)
          Wraps the actual subscription once it exists (if it wasn't available when constructed)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SafeObservableSubscription

public SafeObservableSubscription()

SafeObservableSubscription

public SafeObservableSubscription(Subscription actualSubscription)
Method Detail

wrap

public SafeObservableSubscription wrap(Subscription actualSubscription)
Wraps the actual subscription once it exists (if it wasn't available when constructed)

Parameters:
actualSubscription - the wrapped subscription
Throws:
java.lang.IllegalStateException - if trying to set more than once (or use this method after setting via constructor)

unsubscribe

public void unsubscribe()
Description copied from interface: Subscription
Stop receiving notifications on the Observer that was registered when this Subscription was received.

This allows unregistering an Observer before it has finished receiving all events (ie. before onCompleted is called).

Specified by:
unsubscribe in interface Subscription

isUnsubscribed

public boolean isUnsubscribed()