Interface LiveMap<T>

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).

Type Parameters

Hierarchy

Methods

  • Experimental

    Returns an iterable of key-value pairs for every entry in the map.

    Type Parameters

    • TKey extends string

    Returns IterableIterator<[TKey, T[TKey]]>

  • 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.

    Type Parameters

    • TKey extends string

    Parameters

    • key: TKey

      The key to retrieve the value for.

    Returns undefined | T[TKey]

    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

    Returns an iterable of keys in the map.

    Type Parameters

    • TKey extends string

    Returns IterableIterator<TKey>

  • Experimental

    Removes all registrations that match both the specified listener and the specified event.

    Parameters

    Returns void

  • Experimental

    Deregisters all registrations, for all events and listeners.

    Returns void

  • 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.

    Type Parameters

    • TKey extends string

    Parameters

    • key: TKey

      The key to remove.

    Returns Promise<void>

    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.

    Type Parameters

    • TKey extends string

    Parameters

    • key: TKey

      The key to set the value for.

    • value: T[TKey]

      The value to assign to the key.

    Returns Promise<void>

    A promise which resolves upon success of the operation and rejects with an ErrorInfo object upon its failure.

  • Experimental

    Returns the number of key-value pairs in the map.

    Returns number

  • Experimental

    Returns an iterable of values in the map.

    Type Parameters

    • TKey extends string

    Returns IterableIterator<T[TKey]>

Generated using TypeDoc