Package io.objectbox.reactive
Class DataSubscriptionList
java.lang.Object
io.objectbox.reactive.DataSubscriptionList
- All Implemented Interfaces:
DataSubscription
Tracks any number of
DataSubscription
objects, which can be canceled with a single cancel()
call.
This is typically used in live cycle components like Android's Activity:
- Make DataSubscriptionList a field
- Call
add(DataSubscription)
during onStart/onResume for each subscription - Call
cancel()
during onStop/onPause
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(DataSubscription subscription) Add the given subscription to the list of tracked subscriptions.void
cancel()
Cancels all tracked subscriptions and removes all references to them.int
Returns number of active (added) subscriptions (resets to 0 aftercancel()
).boolean
Returns true ifcancel()
was called without any subsequent calls toadd(DataSubscription)
.
-
Constructor Details
-
DataSubscriptionList
public DataSubscriptionList()
-
-
Method Details
-
add
Add the given subscription to the list of tracked subscriptions. Clears any previous "canceled" state. -
cancel
public void cancel()Cancels all tracked subscriptions and removes all references to them.- Specified by:
cancel
in interfaceDataSubscription
-
isCanceled
public boolean isCanceled()Returns true ifcancel()
was called without any subsequent calls toadd(DataSubscription)
.- Specified by:
isCanceled
in interfaceDataSubscription
-
getActiveSubscriptionCount
public int getActiveSubscriptionCount()Returns number of active (added) subscriptions (resets to 0 aftercancel()
).
-