Skip to main content
LiveObjects operations define how object data is updated and synchronized across multiple clients. When you create or update an object, the change is expressed as an operation that is sent as an object message on the channel. The operation is then applied to the object instance on all clients that are subscribed to the channel. This document explains the key concepts you need to know when working with operations.

Operation types

Each object type supports specific operations that modify the object’s data.

LiveMap operations

LiveMap supports the following operations:
  • set: Set a value for a key
  • remove: Remove a key and its value
The value of an entry in a LiveMap instance can be a primitive type or a reference to another object.

LiveCounter operations

LiveCounter supports the following operations:
  • increment: Increment the counter by a specified amount
  • decrement: Decrement the counter by a specified amount
The amount is a double-precision floating-point number, which is the same as underlying type of a LiveCounter value.

Create operations

Create operations are used to instantiate new objects of a given type. Use LiveMap.create() and LiveCounter.create() to create new objects. These methods create special value types that can be assigned directly to paths:
When a create operation is processed, an object ID is automatically generated for the new object instance.

Object IDs

Every operation is expressed relative to a specific object instance, identified by its object ID, which determines which object the operation is applied to. When using a PathObject, the specific object instance at the given path is evaluated at the time a method is called that updates the object. The client library will then publish an operation targeting the resolved object. When using a client library object IDs are handled automatically, allowing you work directly with object references:

Batch operations

Batch operations can be used to batch a set of operations together:
  • Multiple operations are grouped into a single atomic unit
  • All operations in the batch either succeed together or fail together
  • Operations in a batch are sent as a single message
  • No operations from other clients can be interleaved within a batch

Object message properties

Each operation is carried by an ObjectMessage, which is surfaced in subscriptions and provides metadata about the operation and who performed it.

ObjectMessage

The following are the properties of an ObjectMessage:

ObjectOperation

The operation field of an ObjectMessage contains an ObjectOperation with the following properties:

ObjectData

The data field in mapOp is an ObjectData object that represents the value assigned to a map key. It has the following properties: