Interface AnyOperations

Defines all possible operations available on LiveObjects.

Hierarchy

Methods

  • Batch multiple operations together using a batch context, which wraps the underlying PathObject or Instance from which the batch was called. The batch context always contains a resolved instance, even when called from a PathObject. If an instance cannot be resolved from the referenced path, or if the instance is not a LiveObject, this method throws an error.

    Batching enables you to group multiple operations together and send them to the Ably service in a single channel message. As a result, other clients will receive the changes in a single channel message once the batch function has completed.

    The objects' data is not modified inside the batch function. Instead, the objects will be updated when the batched operations are applied by the Ably service and echoed back to the client.

    Type Parameters

    Parameters

    Returns Promise<void>

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

  • An alias for calling increment(-amount)

    Parameters

    • Optional amount: number

      The amount by which to decrease the counter value. If not provided, defaults to 1.

    Returns Promise<void>

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

  • Sends an operation to the Ably system to increment the value of the underlying counter when using AnyInstance, or of the counter instance resolved from the path when using AnyPathObject.

    If called via AnyInstance and the underlying instance at runtime is not a counter, or if called via AnyPathObject and the counter instance at the specified path cannot be resolved at the time of the call, this method throws an error.

    This does not modify the underlying data of the counter. 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

    • Optional amount: number

      The amount by which to increase the counter value. If not provided, defaults to 1.

    Returns Promise<void>

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

  • Sends an operation to the Ably system to remove a key from the underlying map when using AnyInstance, or from the map instance resolved from the path when using AnyPathObject.

    If called via AnyInstance and the underlying instance at runtime is not a map, or if called via AnyPathObject and the map instance at the specified path cannot be resolved at the time of the call, 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

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

    Parameters

    • key: keyof T & string

      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.

  • Sends an operation to the Ably system to set a key to a specified value on the underlying map when using AnyInstance, or on the map instance resolved from the path when using AnyPathObject.

    If called via AnyInstance and the underlying instance at runtime is not a map, or if called via AnyPathObject and the map instance at the specified path cannot be resolved at the time of the call, 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

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

    Parameters

    • key: keyof T & string

      The key to set the value for.

    • value: T[keyof T]

      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.

Generated using TypeDoc