Experimental
Returns the value associated with a given key. Returns undefined
if the key doesn't exist in a map or if the associated LiveObject has been deleted.
Always returns undefined if this map object is deleted.
The key to retrieve the value for.
A LiveObject, a primitive type (string, number, boolean, or binary data) or undefined
if the key doesn't exist in a map or the associated LiveObject has been deleted. Always undefined
if this map object is deleted.
Experimental
Removes all registrations that match both the specified listener and the specified event.
The named event.
The event listener.
Experimental
Registers the provided listener for the specified event. If on()
is called more than once with the same listener and event, the listener is added multiple times to its listener registry. Therefore, as an example, assuming the same listener is registered twice using on()
, and an event is emitted once, the listener would be invoked twice.
The named event to listen for.
The event listener.
A OnLiveObjectLifecycleEventResponse object that allows the provided listener to be deregistered from future updates.
Experimental
Sends an operation to the Ably system to remove a key from this LiveMap
object.
This does not modify the underlying data of this object. Instead, the change is applied when the published operation is echoed back to the client and applied to the object. To get notified when object gets updated, use the subscribe method.
The key to remove.
A promise which resolves upon success of the operation and rejects with an ErrorInfo object upon its failure.
Experimental
Sends an operation to the Ably system to set a key on this LiveMap
object to a specified value.
This does not modify the underlying data of this object. Instead, the change is applied when the published operation is echoed back to the client and applied to the object. To get notified when object gets updated, use the subscribe method.
The key to set the value for.
The value to assign to the key.
A promise which resolves upon success of the operation and rejects with an ErrorInfo object upon its failure.
Experimental
Registers a listener that is called each time this LiveObject is updated.
An event listener function that is called with an update object whenever this LiveObject is updated.
A SubscribeResponse object that allows the provided listener to be deregistered from future updates.
Experimental
Deregisters the given listener from updates for this LiveObject.
An event listener function.
Generated using TypeDoc
The
LiveMap
class represents a key-value map data structure, similar to a JavaScript Map, where all changes are synchronized across clients in realtime. Conflicts in a LiveMap are automatically resolved with last-write-wins (LWW) semantics, meaning that if two clients update the same key in the map, the update with the most recent timestamp wins.Keys must be strings. Values can be another LiveObject, or a primitive type, such as a string, number, boolean, or binary data (see PrimitiveObjectValue).