-
- All Implemented Interfaces:
-
com.tds.common.reactor.Subscription
public final class CompositeSubscription implements Subscription
Subscription that represents a group of Subscriptions that are unsubscribed together.
All methods of this class are thread-safe.
-
-
Constructor Summary
Constructors Constructor Description CompositeSubscription()
Constructs an empty Composite subscription. CompositeSubscription(Array<Subscription> subscriptions)
-
Method Summary
Modifier and Type Method Description boolean
isUnsubscribed()
Indicates whether this {@code Subscription}
is currently unsubscribed.void
add(Subscription s)
Adds a new Subscription to this {@code CompositeSubscription}
if the{@code CompositeSubscription}
is not yet unsubscribed.void
addAll(Array<Subscription> subscriptions)
Adds collection of Subscription to this {@code CompositeSubscription}
if the{@code CompositeSubscription}
is not yet unsubscribed.void
remove(Subscription s)
Removes a Subscription from this {@code CompositeSubscription}
, and unsubscribes the Subscription.void
clear()
Unsubscribes any subscriptions that are currently part of this {@code CompositeSubscription}
and removethem from the{@code CompositeSubscription}
so that the{@code CompositeSubscription}
is empty andable to manage new subscriptions.void
unsubscribe()
Unsubscribes itself and all inner subscriptions. boolean
hasSubscriptions()
Returns true if this composite is not unsubscribed and contains subscriptions. -
-
Constructor Detail
-
CompositeSubscription
CompositeSubscription()
Constructs an empty Composite subscription.
-
CompositeSubscription
CompositeSubscription(Array<Subscription> subscriptions)
-
-
Method Detail
-
isUnsubscribed
boolean isUnsubscribed()
Indicates whether this
{@code Subscription}
is currently unsubscribed.
-
add
void add(Subscription s)
Adds a new Subscription to this
{@code CompositeSubscription}
if the{@code CompositeSubscription}
is not yet unsubscribed. If the{@code CompositeSubscription}
isunsubscribed,{@code add}
will indicate this by explicitly unsubscribing the new{@code Subscription}
aswell.- Parameters:
s
- the Subscription to add
-
addAll
void addAll(Array<Subscription> subscriptions)
Adds collection of Subscription to this
{@code CompositeSubscription}
if the{@code CompositeSubscription}
is not yet unsubscribed. If the{@code CompositeSubscription}
isunsubscribed,{@code addAll}
will indicate this by explicitly unsubscribing all{@code Subscription}
in collection aswell.- Parameters:
subscriptions
- the collection of Subscription to add
-
remove
void remove(Subscription s)
Removes a Subscription from this
{@code CompositeSubscription}
, and unsubscribes the Subscription.- Parameters:
s
- the Subscription to remove
-
clear
void clear()
Unsubscribes any subscriptions that are currently part of this
{@code CompositeSubscription}
and removethem from the{@code CompositeSubscription}
so that the{@code CompositeSubscription}
is empty andable to manage new subscriptions.
-
unsubscribe
void unsubscribe()
Unsubscribes itself and all inner subscriptions.
After call of this method, new
{@code Subscription}
s added to CompositeSubscription will be unsubscribed immediately.
-
hasSubscriptions
boolean hasSubscriptions()
Returns true if this composite is not unsubscribed and contains subscriptions.
-
-
-
-