diff --git a/docs/collection.js b/docs/collection.js index b0dcaeaa..98824151 100644 --- a/docs/collection.js +++ b/docs/collection.js @@ -259,6 +259,39 @@ class Collection { * @since 0.11.0 */ 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) {} + } /** diff --git a/docs/results.js b/docs/results.js index 6a28f085..d04818e6 100644 --- a/docs/results.js +++ b/docs/results.js @@ -20,7 +20,9 @@ * Instances of this class are typically **live** collections returned by * {@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 - * {@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 * @memberof Realm */ diff --git a/src/object-store b/src/object-store index c3e4be6d..1c2f3a76 160000 --- a/src/object-store +++ b/src/object-store @@ -1 +1 @@ -Subproject commit c3e4be6d6cd0bf3e010e169b9793087e60eb52bb +Subproject commit 1c2f3a7607467ed904a81a4824d0cbda33cc0ebb