diff --git a/src/pages/docs/liveobjects/batch.mdx b/src/pages/docs/liveobjects/batch.mdx index 04b5734a71..a1a3144356 100644 --- a/src/pages/docs/liveobjects/batch.mdx +++ b/src/pages/docs/liveobjects/batch.mdx @@ -256,7 +256,7 @@ When a batch operation is applied, the subscription is notified synchronously an ```javascript // Subscribe to the channel object myObject.subscribe(({ object, message }) => { - console.log("Update:", message?.operation.action, message?.operation?.mapOp.key); + console.log("Update:", message?.operation.action, message?.operation?.mapSet?.key); }); // Perform a batch operation diff --git a/src/pages/docs/liveobjects/concepts/operations.mdx b/src/pages/docs/liveobjects/concepts/operations.mdx index 888881dea6..2cef04c076 100644 --- a/src/pages/docs/liveobjects/concepts/operations.mdx +++ b/src/pages/docs/liveobjects/concepts/operations.mdx @@ -331,18 +331,24 @@ The `operation` field of an `ObjectMessage` contains an `ObjectOperation` with t |----------|-------------| | **action** | The operation action. One of: `'map.create'`, `'map.set'`, `'map.remove'`, `'counter.create'`, `'counter.inc'`, or `'object.delete'` | | **objectId** | The ID of the object the operation was applied to | -| **mapOp** | Present for map mutation operations (`'map.set'`, `'map.remove'`). Contains `key` (the key that was modified) and optionally `data` (an `ObjectData` representing the value assigned to the key, present only for `'map.set'` operations) | -| **counterOp** | Present for counter increment operations (`'counter.inc'`). Contains `amount` (the value added to the counter) | -| **map** | Present for `'map.create'` operations. Defines the initial value of the map object with optional `semantics` (conflict-resolution strategy) and `entries` (initial key-value pairs) | -| **counter** | Present for `'counter.create'` operations. Defines the initial value of the counter object with optional `count` (initial counter value) | +| **mapCreate** | Present for `'map.create'` operations. Defines the initial value of the map object with `semantics` (conflict-resolution strategy) and `entries` (initial key-value pairs) | +| **mapSet** | Present for `'map.set'` operations. Contains `key` (the key that was set) and `value` (an `ObjectData` representing the value assigned to the key) | +| **mapRemove** | Present for `'map.remove'` operations. Contains `key` (the key that was removed) | +| **counterCreate** | Present for `'counter.create'` operations. Defines the initial value of the counter object with `count` (initial counter value) | +| **counterInc** | Present for `'counter.inc'` operations. Contains `number` (the value added to the counter) | +| **objectDelete** | Present for `'object.delete'` operations. Empty object with no operation-specific data | #### ObjectData -The `data` field in `mapOp` is an `ObjectData` object that represents the value assigned to a map key. It has the following properties: +The `value` field in `mapSet` is an `ObjectData` object that represents the value assigned to a map key. Exactly one property is set, indicating the type of data: | Property | Description | |----------|-------------| -| **objectId** | A reference to another object (such as a `LiveMap` or `LiveCounter`) by its object ID. Present when the value is a LiveObject | -| **value** | A decoded primitive value (string, number, boolean, JSON-serializable object or array, or binary data). Present when the value is a primitive type | +| **objectId** | A reference to another object (such as a `LiveMap` or `LiveCounter`) by its object ID | +| **boolean** | A boolean leaf value | +| **bytes** | A binary leaf value (`ArrayBuffer` in browser environments, or `Buffer` in Node.js) | +| **number** | A numeric leaf value | +| **string** | A string leaf value | +| **json** | A parsed JSON object or array leaf value | diff --git a/src/pages/docs/liveobjects/concepts/path-object.mdx b/src/pages/docs/liveobjects/concepts/path-object.mdx index 929776e52e..f646cb95d1 100644 --- a/src/pages/docs/liveobjects/concepts/path-object.mdx +++ b/src/pages/docs/liveobjects/concepts/path-object.mdx @@ -536,15 +536,15 @@ When subscribed to a `LiveMap`, the `object` passed to the subscription is a `Pa // Subscribe to a LiveCounter stored in 'visits' const visits = myObject.get('visits'); visits.subscribe(({ object, message }) => { - console.log('path:', object.path(), 'amount:', message?.operation?.counterOp?.amount); + console.log('path:', object.path(), 'number:', message?.operation?.counterInc?.number); }); await visits.increment(5); -// path: visits amount: 5 +// path: visits number: 5 // Subscribe to a LiveMap stored in 'settings' const settings = myObject.get('settings'); settings.subscribe(({ object, message }) => { - console.log('path:', object.path(), 'key:', message?.operation?.mapOp?.key); + console.log('path:', object.path(), 'key:', message?.operation?.mapSet?.key); }); await settings.set('theme', 'dark'); // path: settings key: theme @@ -555,7 +555,7 @@ await settings.get('preferences').set('language', 'en'); const settings = myObject.get('settings'); const theme = settings.get('theme'); theme.subscribe(({ object, message }) => { - console.log('path:', object.path(), 'key:', message?.operation?.mapOp?.key); + console.log('path:', object.path(), 'key:', message?.operation?.mapSet?.key); }); await settings.set('theme', 'dark'); // path: settings.theme key: theme