Skip to main content
LiveMap is a synchronized key/value data structure that stores primitive values, such as numbers, strings, booleans, binary data, JSON-serializable objects or arrays and other live object types. It ensures that all updates are correctly applied and synchronized across clients in realtime, automatically resolving conflicts with last-write-wins (LWW) semantics. You interact with LiveMap through a PathObject or by obtaining a specific Instance.

Create a map

Create a LiveMap using the LiveMap.create() static method and assign it to a path:
LiveMap.create() returns a value type that describes the initial data for a new map. The actual object is created when assigned to a path. Each assignment creates a distinct object with its own unique ID:

Get map values

Access a LiveMap through a PathObject for path-based operations, or obtain a specific Instance to work with the underlying object directly. Use the get() method to navigate to entries within the map. What you can do with the result depends on the type of value stored in the entry:
  • For entries containing primitive values or LiveCounter objects, use the value() method to get the current value.
  • For entries containing nested LiveMap objects, use get() to continue navigating deeper into the structure.

Get compact object

Get a JavaScript object representation of the map using the compact() or compactJson() methods:

Set map values

Set a value for a key in the map using the set() method. You can store primitive values or other live object types:

Remove a key

Remove a key from the map using the remove() method:

Get map size

Get the number of keys in the map using the size() method:

Enumerate entries

Iterate over the map’s keys, values, or entries. When iterating using a PathObject, values are returned as a PathObject for the nested path. When iterating using an Instance, values are returned as an Instance for the entry:

Batch multiple operations

Group multiple map operations into a single atomic message using the batch() method. All operations within the batch are sent as one logical unit which succeed or fail together:

Subscribe to updates

Subscribe to LiveMap updates to receive realtime notifications when the map changes. PathObject subscriptions observe a location and automatically track changes even if the LiveMap instance at that path is replaced. Instance subscriptions track a specific LiveMap instance, following it even if it moves in the channel object.
Alternatively, use the subscribeIterator() method for an async iterator syntax: