public final class Subscriptions extends Object
Subscription objects
| Modifier and Type | Method and Description |
|---|---|
static Subscription |
create(Action0
Creates and returns a
Subscription that invokes the given
Action0 when unsubscribed.
|
static Subscription |
empty()
|
static Subscription |
from(Future
Converts a
Future into a
Subscription and cancels it when unsubscribed.
|
static CompositeSubscription |
from(Subscription
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 Subscriptionempty()
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
true
@Experimental public static Subscriptionunsubscribed()
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 unsubscribed
public static Subscriptioncreate(Action0 unsubscribe)
Subscription that invokes the given
Action0 when unsubscribed.
unsubscribe - Action to invoke on unsubscribe.
Subscription
public static Subscriptionfrom(Future <?> f)
Future into a
Subscription and cancels it when unsubscribed.
f - the
Future to convert
Subscription that wraps
f
public static CompositeSubscriptionfrom(Subscription ... subscriptions)
Subscriptions into a
CompositeSubscription that groups the multiple Subscriptions together and unsubscribes from all of them together.
subscriptions - the Subscriptions to group together
CompositeSubscription representing the
subscriptions set