SubscriptionSet

interface SubscriptionSet<T : BaseRealm> : BaseSubscriptionSet

A subscription set is an immutable view of all current Subscriptions for a given Realm that has been configured for Flexible Sync.

Flexible Sync is a way of defining which data gets synchronized to and from the device using RealmQuerys. The query and its metadata are represented by a Subscription.

A subscription set thus defines all the data that is available to the device and being synchronized with the server. If the subscription set encounters an error, e.g. by containing an invalid query, the entire subscription set will enter an SubscriptionSetState.ERROR state, and no synchronization will happen until the error has been fixed.

If a subscription is removed, so is the corresponding data, but it is only removed from the device. It isn't deleted on the server.

It is possible to modify a subscription set while offline, but a modification isn't accepted by the server before BaseSubscriptionSet.state returns SubscriptionSetState.COMPLETE, which requires that the device has been online.

It is possible to wait for the subscription set to be synchronized with the server by using waitForSynchronization.

Functions

findByName
Link copied to clipboard
abstract fun findByName(name: String): Subscription?
Find the subscription with a given name.
findByQuery
Link copied to clipboard
abstract fun <T : RealmObject> findByQuery(query: RealmQuery<T>): Subscription?
Find the first subscription that contains the given query.
iterator
Link copied to clipboard
abstract operator fun iterator(): Iterator<Subscription>
refresh
Link copied to clipboard
abstract fun refresh(): SubscriptionSet<T>
Refresh the state of the subscription set, so it reflect the latest underlying state of the subscriptions.
update
Link copied to clipboard
abstract suspend fun update(block: MutableSubscriptionSet.(T) -> Unit): SubscriptionSet<T>
Modify the subscription set.
waitForSynchronization
Link copied to clipboard
abstract suspend fun waitForSynchronization(timeout: Duration = Duration.INFINITE): Boolean
Wait for the subscription set to synchronize with the server.

Properties

errorMessage
Link copied to clipboard
abstract val errorMessage: String?
If state returns SubscriptionSetState.ERROR, this method will return the reason.
size
Link copied to clipboard
abstract val size: Int
The number of subscriptions currently in this subscription set.
state
Link copied to clipboard
abstract val state: SubscriptionSetState
The current state of the SubscriptionSet.