Package io.objectbox.reactive
Class DataSubscriptionList
- java.lang.Object
-
- io.objectbox.reactive.DataSubscriptionList
-
- All Implemented Interfaces:
DataSubscription
public class DataSubscriptionList extends java.lang.Object implements DataSubscription
Tracks any number ofDataSubscriptionobjects, which can be canceled with a singlecancel()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 Constructor Description DataSubscriptionList()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(DataSubscription subscription)Add the given subscription to the list of tracked subscriptions.voidcancel()Cancels all tracked subscriptions and removes all references to them.intgetActiveSubscriptionCount()Returns number of active (added) subscriptions (resets to 0 aftercancel()).booleanisCanceled()Returns true ifcancel()was called without any subsequent calls toadd(DataSubscription).
-
-
-
Method Detail
-
add
public void add(DataSubscription subscription)
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:
cancelin interfaceDataSubscription
-
isCanceled
public boolean isCanceled()
Returns true ifcancel()was called without any subsequent calls toadd(DataSubscription).- Specified by:
isCanceledin interfaceDataSubscription
-
getActiveSubscriptionCount
public int getActiveSubscriptionCount()
Returns number of active (added) subscriptions (resets to 0 aftercancel()).
-
-