Package rx.subscriptions
Class CompositeSubscription
java.lang.Object
rx.subscriptions.CompositeSubscription
- All Implemented Interfaces:
Subscription
Subscription that represents a group of Subscriptions that are unsubscribed together.
All methods of this class are thread-safe.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty Composite subscription.CompositeSubscription(Subscription... subscriptions) -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(Subscription s) Adds a newSubscriptionto thisCompositeSubscriptionif theCompositeSubscriptionis not yet unsubscribed.voidaddAll(Subscription... subscriptions) Adds collection ofSubscriptionto thisCompositeSubscriptionif theCompositeSubscriptionis not yet unsubscribed.voidclear()Unsubscribes any subscriptions that are currently part of thisCompositeSubscriptionand remove them from theCompositeSubscriptionso that theCompositeSubscriptionis empty and able to manage new subscriptions.booleanReturns true if this composite is not unsubscribed and contains subscriptions.booleanIndicates whether thisSubscriptionis currently unsubscribed.voidvoidUnsubscribes itself and all inner subscriptions.private static voidunsubscribeFromAll(Collection<Subscription> subscriptions)
-
Field Details
-
subscriptions
-
unsubscribed
private volatile boolean unsubscribed
-
-
Constructor Details
-
CompositeSubscription
public CompositeSubscription()Constructs an empty Composite subscription. -
CompositeSubscription
-
-
Method Details
-
isUnsubscribed
public boolean isUnsubscribed()Description copied from interface:SubscriptionIndicates whether thisSubscriptionis currently unsubscribed.- Specified by:
isUnsubscribedin interfaceSubscription- Returns:
trueif thisSubscriptionis currently unsubscribed,falseotherwise
-
add
Adds a newSubscriptionto thisCompositeSubscriptionif theCompositeSubscriptionis not yet unsubscribed. If theCompositeSubscriptionis unsubscribed,addwill indicate this by explicitly unsubscribing the newSubscriptionas well.- Parameters:
s- theSubscriptionto add
-
addAll
Adds collection ofSubscriptionto thisCompositeSubscriptionif theCompositeSubscriptionis not yet unsubscribed. If theCompositeSubscriptionis unsubscribed,addAllwill indicate this by explicitly unsubscribing allSubscriptionin collection as well.- Parameters:
subscriptions- the collection ofSubscriptionto add
-
remove
- Parameters:
s- theSubscriptionto remove
-
clear
public void clear()Unsubscribes any subscriptions that are currently part of thisCompositeSubscriptionand remove them from theCompositeSubscriptionso that theCompositeSubscriptionis empty and able to manage new subscriptions. -
unsubscribe
public void unsubscribe()Unsubscribes itself and all inner subscriptions.After call of this method, new
Subscriptions added toCompositeSubscriptionwill be unsubscribed immediately.- Specified by:
unsubscribein interfaceSubscription
-
unsubscribeFromAll
-
hasSubscriptions
public boolean hasSubscriptions()Returns true if this composite is not unsubscribed and contains subscriptions.- Returns:
trueif this composite is not unsubscribed and contains subscriptions.- Since:
- 1.0.7
-