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 TypeMethodDescriptionvoid
add
(Subscription s) Adds a newSubscription
to thisCompositeSubscription
if theCompositeSubscription
is not yet unsubscribed.void
addAll
(Subscription... subscriptions) Adds collection ofSubscription
to thisCompositeSubscription
if theCompositeSubscription
is not yet unsubscribed.void
clear()
Unsubscribes any subscriptions that are currently part of thisCompositeSubscription
and remove them from theCompositeSubscription
so that theCompositeSubscription
is empty and able to manage new subscriptions.boolean
Returns true if this composite is not unsubscribed and contains subscriptions.boolean
Indicates whether thisSubscription
is currently unsubscribed.void
void
Unsubscribes itself and all inner subscriptions.private static void
unsubscribeFromAll
(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:Subscription
Indicates whether thisSubscription
is currently unsubscribed.- Specified by:
isUnsubscribed
in interfaceSubscription
- Returns:
true
if thisSubscription
is currently unsubscribed,false
otherwise
-
add
Adds a newSubscription
to thisCompositeSubscription
if theCompositeSubscription
is not yet unsubscribed. If theCompositeSubscription
is unsubscribed,add
will indicate this by explicitly unsubscribing the newSubscription
as well.- Parameters:
s
- theSubscription
to add
-
addAll
Adds collection ofSubscription
to thisCompositeSubscription
if theCompositeSubscription
is not yet unsubscribed. If theCompositeSubscription
is unsubscribed,addAll
will indicate this by explicitly unsubscribing allSubscription
in collection as well.- Parameters:
subscriptions
- the collection ofSubscription
to add
-
remove
- Parameters:
s
- theSubscription
to remove
-
clear
public void clear()Unsubscribes any subscriptions that are currently part of thisCompositeSubscription
and remove them from theCompositeSubscription
so that theCompositeSubscription
is empty and able to manage new subscriptions. -
unsubscribe
public void unsubscribe()Unsubscribes itself and all inner subscriptions.After call of this method, new
Subscription
s added toCompositeSubscription
will be unsubscribed immediately.- Specified by:
unsubscribe
in interfaceSubscription
-
unsubscribeFromAll
-
hasSubscriptions
public boolean hasSubscriptions()Returns true if this composite is not unsubscribed and contains subscriptions.- Returns:
true
if this composite is not unsubscribed and contains subscriptions.- Since:
- 1.0.7
-