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 classNaming classes helps with debugging.(package private) static final classNaming classes helps with debugging. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Subscriptions.UnsubscribedASubscriptionthat does nothing when its unsubscribe method is called. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SubscriptionCreates and returns aSubscriptionthat invokes the givenAction0when unsubscribed.static Subscriptionempty()static SubscriptionConverts aFutureinto aSubscriptionand cancels it when unsubscribed.static CompositeSubscriptionfrom(Subscription... subscriptions) Converts a set ofSubscriptions into aCompositeSubscriptionthat groups the multiple Subscriptions together and unsubscribes from all of them together.static SubscriptionReturns aSubscriptionto whichunsubscribedoes nothing, as it is already unsubscribed.
-
Field Details
-
UNSUBSCRIBED
ASubscriptionthat does nothing when its unsubscribe method is called.
-
-
Constructor Details
-
Subscriptions
private Subscriptions()
-
-
Method Details
-
empty
Returns aSubscriptionto whichunsubscribedoes nothing except to changeisUnsubscribedtotrue. It's stateful andisUnsubscribedindicates ifunsubscribeis 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
Subscriptionto whichunsubscribedoes nothing except to changeisUnsubscribedtotrue
-
unsubscribed
Returns aSubscriptionto whichunsubscribedoes nothing, as it is already unsubscribed. ItsisUnsubscribedalways returnstrue, which is different fromempty().Subscription unsubscribed = Subscriptions.unsubscribed(); System.out.println(unsubscribed.isUnsubscribed()); // true- Returns:
- a
Subscriptionto whichunsubscribedoes nothing, as it is already unsubscribed - Since:
- 1.1.0
-
create
Creates and returns aSubscriptionthat invokes the givenAction0when unsubscribed.- Parameters:
unsubscribe- Action to invoke on unsubscribe.- Returns:
Subscription
-
from
Converts aFutureinto aSubscriptionand cancels it when unsubscribed.- Parameters:
f- theFutureto convert- Returns:
- a
Subscriptionthat wrapsf
-
from
Converts a set ofSubscriptions into aCompositeSubscriptionthat groups the multiple Subscriptions together and unsubscribes from all of them together.- Parameters:
subscriptions- the Subscriptions to group together- Returns:
- a
CompositeSubscriptionrepresenting thesubscriptionsset
-