Interface LiveMapBatchContext<T>

LiveMapBatchContext is a batch context wrapper for a LiveMap object. The type parameter T describes the expected structure of the map's entries.

Type Parameters

  • T extends Record<string, Value> = Record<string, Value>

Hierarchy

Properties

id: undefined | string

Get the object ID of the underlying instance.

If the underlying instance at runtime is not a LiveObject, returns undefined.

Methods

  • Get an in-memory JavaScript object representation of the map instance. Cyclic references are handled through memoization, returning shared compacted object references for previously visited objects. This means the value returned from compact() cannot be directly JSON-stringified if the object may contain cycles.

    If the underlying instance's value is not of the expected type at runtime, returns undefined.

    Use compactJson() for a JSON-serializable representation.

    Returns undefined | {
        [K in string | number | symbol]: CompactedValue<T[K]>
    }

  • Get a JSON-serializable representation of the map instance. Binary values are converted to base64-encoded strings. Cyclic references are represented as { objectId: string } instead of in-memory pointers, making the result safe to pass to JSON.stringify().

    If the underlying instance's value is not of the expected type at runtime, returns undefined.

    Use compact() for an in-memory representation.

    Returns undefined | ObjectIdReference | {
        [K in string | number | symbol]: CompactedJsonValue<T[K]>
    }

  • Returns the value associated with a given key as a BatchContext.

    Returns undefined if the key doesn't exist in the map, if the referenced LiveObject has been deleted, or if this map object itself has been deleted.

    Type Parameters

    • K extends string

    Parameters

    • key: K

      The key to retrieve the value for.

    Returns undefined | BatchContext<T[K]>

    A BatchContext representing a LiveObject, a primitive type (string, number, boolean, JSON-serializable object or array, or binary data) or undefined if the key doesn't exist in a map or the referenced LiveObject has been deleted. Always undefined if this map object is deleted.

  • Adds an operation to the current batch to remove a key from the underlying LiveMapInstance. All queued operations are sent together in a single message once the batch function completes.

    If the underlying instance at runtime is not a map, this method throws an error.

    This does not modify the underlying data of the map. 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 PathObject.subscribe or Instance.subscribe, as appropriate.

    Parameters

    • key: keyof T & string

      The key to remove.

    Returns void

  • Adds an operation to the current batch to set a key to a specified value on the underlying LiveMapInstance. All queued operations are sent together in a single message once the batch function completes.

    If the underlying instance at runtime is not a map, this method throws an error.

    This does not modify the underlying data of the map. 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 PathObject.subscribe or Instance.subscribe, as appropriate.

    Type Parameters

    • K extends string

    Parameters

    • key: K

      The key to set the value for.

    • value: T[K]

      The value to assign to the key.

    Returns void

Generated using TypeDoc