public final class Subscriptions extends java.lang.Object Subscription objects| Modifier and Type | Method and Description |
|---|---|
static Subscription | create(Action0 unsubscribe) Creates and returns a Subscription that invokes the given Action0 when unsubscribed. |
static Subscription | empty() |
static Subscription | from(java.util.concurrent.Future<?> f) Converts a Future into a Subscription and cancels it when unsubscribed. |
static CompositeSubscription | from(Subscription... subscriptions) Converts a set of Subscriptions into a CompositeSubscription that groups the multiple Subscriptions together and unsubscribes from all of them together. |
static Subscription | unsubscribed() Returns a Subscription to which unsubscribe does nothing, as it is already unsubscribed. |
public static Subscription empty()
Subscription to which unsubscribe does nothing except to change isUnsubscribed to true. It's stateful and isUnsubscribed indicates if unsubscribe is called, which is different from unsubscribed(). Subscription empty = Subscriptions.empty(); System.out.println(empty.isUnsubscribed()); // false empty.unsubscribe(); System.out.println(empty.isUnsubscribed()); // true Subscription to which unsubscribe does nothing except to change isUnsubscribed to truepublic static Subscription unsubscribed()
Subscription to which unsubscribe does nothing, as it is already unsubscribed. Its isUnsubscribed always returns true, which is different from empty(). Subscription unsubscribed = Subscriptions.unsubscribed(); System.out.println(unsubscribed.isUnsubscribed()); // true Subscription to which unsubscribe does nothing, as it is already unsubscribedpublic static Subscription create(Action0 unsubscribe)
Subscription that invokes the given Action0 when unsubscribed.unsubscribe - Action to invoke on unsubscribe.Subscriptionpublic static Subscription from(java.util.concurrent.Future<?> f)
Future into a Subscription and cancels it when unsubscribed.f - the Future to convertSubscription that wraps fpublic static CompositeSubscription from(Subscription... subscriptions)
Subscriptions into a CompositeSubscription that groups the multiple Subscriptions together and unsubscribes from all of them together.subscriptions - the Subscriptions to group togetherCompositeSubscription representing the subscriptions set