Abstract
Abstract
[iterator]This is the same method as the Collection.values method.
Its presence makes collections iterable, thus able to be used with ES6
for-of
loops,
...
spread operators, and more.
An iterable of each value in the collection.
Symbol.iterator and the iterable protocol
for (let object of collection) {
// do something with each object
}
0.11.0
Add a listener callback
which will be called when a live collection instance changes.
A function to be called when changes occur.
Optional
keyPaths: string | string[]Indicates a lower bound on the changes relevant for the listener. This is a lower bound, since if multiple listeners are added (each with their own keyPaths
) the union of these key-paths will determine the changes that are considered relevant for all listeners registered on the collection. In other words: A listener might fire more than the key-paths specify, if other listeners with different key-paths are present.
deletions and
oldModificationsreport the indices in the collection before the change happened, while
insertionsand
newModificationsreport the indices into the new version of the collection. @throws A {@link TypeAssertionError} if
callback is not a function. @example wines.addListener((collection, changes) => { // collection === wines console.log(
${changes.insertions.length} insertions); console.log(
${changes.oldModifications.length} oldModifications); console.log(
${changes.newModifications.length} newModifications); console.log(
${changes.deletions.length} deletions); console.log(
new size of collection: ${collection.length}); }); @example wines.addListener((collection, changes) => { console.log("A wine's brand might have changed"); }, ["brand"]); @note Adding the listener is an asynchronous operation, so the callback is invoked the first time to notify the caller when the listener has been added. Thus, when the callback is invoked the first time it will contain empty arrays for each property in the
changes` object.
Abstract
entriesAbstract
isAbstract
keysRemove the listener callback
from the collection instance.
Callback function that was previously added as a listener through the Collection.addListener method.
a TypeAssertionError If callback
is not a function.
Abstract
valuesGenerated using TypeDoc
Abstract base class containing methods shared by Realm List, Dictionary and Results.
A Collection always reflect the current state of the Realm. The one exception to this is when using
for...in
orfor...of
enumeration, which will always enumerate over the objects which matched the query when the enumeration is begun, even if some of them are deleted or modified to be excluded by the filter during the enumeration.Since
0.11.0