Add documentation for new methods

This commit is contained in:
Søren Vind 2016-11-14 15:33:23 -08:00
parent f2273c6bd5
commit 862764410a
3 changed files with 37 additions and 2 deletions

View File

@ -259,6 +259,39 @@ class Collection {
* @since 0.11.0 * @since 0.11.0
*/ */
reduceRight(callback, initialValue) {} reduceRight(callback, initialValue) {}
/**
* Add a listener `callback` which will be called when a **live** collection instance changes.
* @param {function(collection, changes)} callback - A function to be called when changes occur.
* The callback function is called with two arguments:
* - `collection`: the collection instance that changed,
* - `changes`: a dictionary with keys `insertions`, `modifications` and `deletions`,
* each containing a list of indices that were inserted, updated or deleted respectively.
* @throws {Error} If `callback` is not a function.
* @example
* wines.addListener((collection, changes) => {
* // collection === wines
* console.log(`${changes.insertions.length} insertions`);
* console.log(`${changes.modifications.length} modifications`);
* console.log(`${changes.deletions.length} deletions`);
* console.log(`new size of collection: ${collection.length}`);
* });
*/
addListener(callback) {}
/**
* Remove the listener `callback` from the collection instance.
* @param {function(collection, changes)} callback - Callback function that was previously
* added as a listener through the {@link Collection#addListener addListener} method.
* @throws {Error} If `callback` is not a function.
*/
removeListener(callback) {}
/**
* Remove all `callback` listeners from the collection instance.
*/
removeAllListeners(name) {}
} }
/** /**

View File

@ -20,7 +20,9 @@
* Instances of this class are typically **live** collections returned by * Instances of this class are typically **live** collections returned by
* {@link Realm#objects objects()} that will update as new objects are either * {@link Realm#objects objects()} that will update as new objects are either
* added to or deleted from the Realm that match the underlying query. Results returned by * added to or deleted from the Realm that match the underlying query. Results returned by
* {@link Realm.Results#snapshot snapshot()}, however, are will **not** live update. * {@link Realm.Results#snapshot snapshot()}, however, will **not** live update
* (and listener callbacks added through {@link Realm.Results#addListener addListener()}
* will thus never be called).
* @extends Realm.Collection * @extends Realm.Collection
* @memberof Realm * @memberof Realm
*/ */

@ -1 +1 @@
Subproject commit c3e4be6d6cd0bf3e010e169b9793087e60eb52bb Subproject commit 1c2f3a7607467ed904a81a4824d0cbda33cc0ebb