mirror of
https://github.com/status-im/realm-js.git
synced 2025-02-04 10:43:29 +00:00
parent
2f20006e47
commit
edfdd933b0
@ -140,9 +140,10 @@ class Collection {
|
||||
* to add a listener.
|
||||
*
|
||||
* @example
|
||||
* let wines = realm.objects('Wine').filtered('vintage <= $0', maxYear).subscribe();
|
||||
* let wines = realm.objects('Wine').filtered('vintage <= $0', maxYear);
|
||||
* let subscription = wines.subscribe();
|
||||
* wines.addListener((collection, changes) => {
|
||||
* if (changes.partial_sync.new_state == Realm.Sync.SubscriptionState.Initialized) {
|
||||
* if (subscription.state === Realm.Sync.SubscriptionState.Complete) {
|
||||
* // update UI
|
||||
* }
|
||||
* });
|
||||
|
@ -500,7 +500,7 @@ class Subscription {
|
||||
|
||||
/**
|
||||
* Adds a listener `callback` which will be called when the state of the subscription changes.
|
||||
* @param {function(state)} callback - A function to be called when changes occur.
|
||||
* @param {function(subscription, state)} callback - A function to be called when changes to the subscription occur.
|
||||
* @throws {Error} If `callback` is not a function.
|
||||
* @example
|
||||
* let subscription = results.subscribe();
|
||||
@ -519,7 +519,7 @@ class Subscription {
|
||||
|
||||
/**
|
||||
* Remove the listener `callback` from the subscription instance.
|
||||
* @param {function(collection, changes)} callback - Callback function that was previously
|
||||
* @param {function(subscription, state)} callback - Callback function that was previously
|
||||
* added as a listener through the {@link Subscription#addListener addListener} method.
|
||||
* @throws {Error} If `callback` is not a function.
|
||||
*/
|
||||
|
2
lib/index.d.ts
vendored
2
lib/index.d.ts
vendored
@ -400,7 +400,7 @@ declare namespace Realm.Sync {
|
||||
removeProgressNotification(progressCallback: ProgressNotificationCallback): void;
|
||||
}
|
||||
|
||||
type SubscriptionNotificationCallback = (state: number) => void;
|
||||
type SubscriptionNotificationCallback = (subscription: Subscription, state: number) => void;
|
||||
|
||||
/**
|
||||
* Subscription
|
||||
|
Loading…
x
Reference in New Issue
Block a user