-
public final class SubscriptionsHelper methods and utilities for creating and working with Subscription objects
-
-
Method Summary
Modifier and Type Method Description static Subscriptionempty()static Subscriptionunsubscribed()Returns a Subscription to which {@code unsubscribe}does nothing, as it is already unsubscribed.static Subscriptioncreate(Action0 unsubscribe)Creates and returns a Subscription that invokes the given Action0 when unsubscribed. static Subscriptionfrom(Future<out Object> f)Converts a Future into a Subscription and cancels it when unsubscribed. static CompositeSubscriptionfrom(Array<Subscription> subscriptions)Converts a set of Subscriptions into a CompositeSubscription that groups the multipleSubscriptions together and unsubscribes from all of them together. -
-
Method Detail
-
empty
static Subscription empty()
-
unsubscribed
static Subscription unsubscribed()
Returns a Subscription to which
{@code unsubscribe}does nothing, as it is already unsubscribed.Its{@code isUnsubscribed}always returns{@code true}, which is different from empty.Subscription unsubscribed = Subscriptions.unsubscribed(); System.out.println(unsubscribed.isUnsubscribed()); // true
-
create
static Subscription create(Action0 unsubscribe)
Creates and returns a Subscription that invokes the given Action0 when unsubscribed.
- Parameters:
unsubscribe- Action to invoke on unsubscribe.
-
from
static Subscription from(Future<out Object> f)
Converts a Future into a Subscription and cancels it when unsubscribed.
- Parameters:
f- the Future to convert
-
from
static CompositeSubscription from(Array<Subscription> subscriptions)
Converts a set of Subscriptions into a CompositeSubscription that groups the multipleSubscriptions together and unsubscribes from all of them together.
- Parameters:
subscriptions- the Subscriptions to group together
-
-
-
-