Package rx.subscriptions
Class Subscriptions
java.lang.Object
rx.subscriptions.Subscriptions
Helper methods and utilities for creating and working with
Subscription
objects-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
Naming classes helps with debugging.(package private) static final class
Naming classes helps with debugging. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Subscriptions.Unsubscribed
ASubscription
that does nothing when its unsubscribe method is called. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Subscription
Creates and returns aSubscription
that invokes the givenAction0
when unsubscribed.static Subscription
empty()
static Subscription
Converts aFuture
into aSubscription
and cancels it when unsubscribed.static CompositeSubscription
from
(Subscription... subscriptions) Converts a set ofSubscription
s into aCompositeSubscription
that groups the multiple Subscriptions together and unsubscribes from all of them together.static Subscription
Returns aSubscription
to whichunsubscribe
does nothing, as it is already unsubscribed.
-
Field Details
-
UNSUBSCRIBED
ASubscription
that does nothing when its unsubscribe method is called.
-
-
Constructor Details
-
Subscriptions
private Subscriptions()
-
-
Method Details
-
empty
Returns aSubscription
to whichunsubscribe
does nothing except to changeisUnsubscribed
totrue
. It's stateful andisUnsubscribed
indicates ifunsubscribe
is called, which is different fromunsubscribed()
.Subscription empty = Subscriptions.empty(); System.out.println(empty.isUnsubscribed()); // false empty.unsubscribe(); System.out.println(empty.isUnsubscribed()); // true
- Returns:
- a
Subscription
to whichunsubscribe
does nothing except to changeisUnsubscribed
totrue
-
unsubscribed
Returns aSubscription
to whichunsubscribe
does nothing, as it is already unsubscribed. ItsisUnsubscribed
always returnstrue
, which is different fromempty()
.Subscription unsubscribed = Subscriptions.unsubscribed(); System.out.println(unsubscribed.isUnsubscribed()); // true
- Returns:
- a
Subscription
to whichunsubscribe
does nothing, as it is already unsubscribed - Since:
- 1.1.0
-
create
Creates and returns aSubscription
that invokes the givenAction0
when unsubscribed.- Parameters:
unsubscribe
- Action to invoke on unsubscribe.- Returns:
Subscription
-
from
Converts aFuture
into aSubscription
and cancels it when unsubscribed.- Parameters:
f
- theFuture
to convert- Returns:
- a
Subscription
that wrapsf
-
from
Converts a set ofSubscription
s into aCompositeSubscription
that groups the multiple Subscriptions together and unsubscribes from all of them together.- Parameters:
subscriptions
- the Subscriptions to group together- Returns:
- a
CompositeSubscription
representing thesubscriptions
set
-