-
public final class Subscriptions
Helper methods and utilities for creating and working with Subscription objects
-
-
Method Summary
Modifier and Type Method Description static Subscription
empty()
static Subscription
unsubscribed()
Returns a Subscription to which {@code unsubscribe}
does nothing, as it is already unsubscribed.static Subscription
create(Action0 unsubscribe)
Creates and returns a Subscription that invokes the given Action0 when unsubscribed. static Subscription
from(Future<out Object> f)
Converts a Future into a Subscription and cancels it when unsubscribed. 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. -
-
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
-
-
-
-