Protected
internalIf state
is SubscriptionSetState.Error, this will be a string representing
why the SubscriptionSet is in an error state. It will be null
if there is no error.
A string representing the error, or null
if there is no error.
Whether there are no subscriptions in the set.
true
if there are no subscriptions in the set, false
otherwise.
The number of subscriptions in the set.
The state of the SubscriptionSet.
The version of the SubscriptionSet. This is incremented every time a SubscriptionSet.update is applied.
The version of the SubscriptionSet.
Makes the subscription set iterable.
Iterable of each value in the set.
for (const subscription of subscriptions) {
// ...
}
Find a subscription by name.
The name to search for.
The named subscription, or null
if the subscription is not found.
Find a subscription by query. Will match both named and unnamed subscriptions.
The query to search for, represented as a Results instance,
e.g. Realm.objects("Cat").filtered("age > 10")
.
The subscription with the specified query, or null
if the subscription is not found.
Call this to make changes to this SubscriptionSet from inside the callback, such as adding or removing subscriptions from the set.
The MutableSubscriptionSet argument can only be used from the callback and must not be used after it returns.
All changes done by the callback will be batched and sent to the server. You can either
await
the call to update
, or call SubscriptionSet.waitForSynchronization
to wait for the new data to be available.
A callback function which receives a MutableSubscriptionSet
instance as the first argument, which can be used to add or remove subscriptions
from the set, and the Realm associated with the SubscriptionSet as the
second argument (mainly useful when working with initialSubscriptions
in
FlexibleSyncConfiguration).
A promise which resolves when the SubscriptionSet is synchronized, or is rejected if there was an error during synchronization (see SubscriptionSet.waitForSynchronization)
await realm.subscriptions.update(mutableSubscriptions => {
mutableSubscriptions.add(realm.objects("Cat").filtered("age > 10"));
mutableSubscriptions.add(realm.objects("Dog").filtered("age > 20"), { name: "oldDogs" });
mutableSubscriptions.removeByName("youngDogs");
});
// `realm` will now return the expected results based on the updated subscriptions
Wait for the server to acknowledge this set of subscriptions and return the matching objects.
If state
is SubscriptionSetState.Complete, the promise will be resolved immediately.
If state
is SubscriptionSetState.Error, the promise will be rejected immediately.
A promise which is resolved when synchronization is complete, or is rejected if there is an error during synchronization.
Generated using TypeDoc
Represents the set of all active flexible sync subscriptions for a Realm instance.
The server will continuously evaluate the queries that the instance is subscribed to and will send data that matches them, as well as remove data that no longer does.
The set of subscriptions can only be modified inside a SubscriptionSet.update callback, by calling methods on the corresponding MutableSubscriptionSet instance.