@ts-expect-error We're exposing methods in the end-users namespace of keys
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.
Removes elements from the dictionary, with the keys provided. This does not throw if the keys are already missing from the dictionary.
The key to be removed.
The dictionary
An AssertionError if not inside a write transaction.
10.6.0 @ts-expect-error We're exposing methods in the end-users namespace of keys
Remove 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.
Adds one or more elements with specified key and value to the dictionary or updates value if key exists.
The dictionary.
an AssertionError If not inside a write transaction, input object contains symbol keys or if any value violates types constraints.
10.6.0 @ts-expect-error We're exposing methods in the end-users namespace of keys
Adds an element with the specified key and value to the dictionary or updates value if key exists.
The key of the element to add.
The value of the element to add.
The dictionary.
an AssertionError If not inside a write transaction, key is a symbol or if value violates type constraints.
12.0.0
The plain object representation for JSON serialization. Use circular JSON serialization libraries such as @ungap/structured-clone and flatted to stringify Realm entities that have circular structures.
Optional
_: stringOptional
cache: unknownA plain object. @ts-expect-error We're exposing methods in the end-users namespace of keys
Generated using TypeDoc
Instances of this class are returned when accessing object properties whose type is
"Dictionary"
Dictionaries behave mostly like a JavaScript object i.e., as a key/value pair where the key is a string.