Updating API docs and TS definitions (closes #1770). (#1707)

This commit is contained in:
Kenneth Geisshirt 2018-03-13 12:45:23 +01:00 committed by GitHub
parent 2f20006e47
commit edfdd933b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -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
* }
* });

View File

@ -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
View File

@ -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