Skip to content

Commit b3830f4

Browse files
VeskeRclaude
andcommitted
Update LiveObjects docs for protocol v6 ObjectOperation fields
The ably-js SDK now exposes per-action fields (mapCreate, mapSet, mapRemove, counterCreate, counterInc, objectDelete) instead of the combined mapOp/counterOp/map/counter properties. ObjectData also exposes typed fields (boolean, bytes, number, string, json) instead of a combined value field. See ably-js PR [1] Resolves AIT-511 [1] ably/ably-js#2159 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e8d88da commit b3830f4

3 files changed

Lines changed: 18 additions & 12 deletions

File tree

src/pages/docs/liveobjects/batch.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ When a batch operation is applied, the subscription is notified synchronously an
256256
```javascript
257257
// Subscribe to the channel object
258258
myObject.subscribe(({ object, message }) => {
259-
console.log("Update:", message?.operation.action, message?.operation?.mapOp.key);
259+
console.log("Update:", message?.operation.action, message?.operation?.mapSet?.key);
260260
});
261261

262262
// Perform a batch operation

src/pages/docs/liveobjects/concepts/operations.mdx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -331,18 +331,24 @@ The `operation` field of an `ObjectMessage` contains an `ObjectOperation` with t
331331
|----------|-------------|
332332
| **action** | The operation action. One of: `'map.create'`, `'map.set'`, `'map.remove'`, `'counter.create'`, `'counter.inc'`, or `'object.delete'` |
333333
| **objectId** | The ID of the object the operation was applied to |
334-
| **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) |
335-
| **counterOp** | Present for counter increment operations (`'counter.inc'`). Contains `amount` (the value added to the counter) |
336-
| **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) |
337-
| **counter** | Present for `'counter.create'` operations. Defines the initial value of the counter object with optional `count` (initial counter value) |
334+
| **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) |
335+
| **mapSet** | Present for `'map.set'` operations. Contains `key` (the key that was set) and `value` (an `ObjectData` representing the value assigned to the key) |
336+
| **mapRemove** | Present for `'map.remove'` operations. Contains `key` (the key that was removed) |
337+
| **counterCreate** | Present for `'counter.create'` operations. Defines the initial value of the counter object with `count` (initial counter value) |
338+
| **counterInc** | Present for `'counter.inc'` operations. Contains `number` (the value added to the counter) |
339+
| **objectDelete** | Present for `'object.delete'` operations. Empty object with no operation-specific data |
338340

339341
#### ObjectData
340342

341-
The `data` field in `mapOp` is an `ObjectData` object that represents the value assigned to a map key. It has the following properties:
343+
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:
342344

343345
| Property | Description |
344346
|----------|-------------|
345-
| **objectId** | A reference to another object (such as a `LiveMap` or `LiveCounter`) by its object ID. Present when the value is a LiveObject |
346-
| **value** | A decoded primitive value (string, number, boolean, JSON-serializable object or array, or binary data). Present when the value is a primitive type |
347+
| **objectId** | A reference to another object (such as a `LiveMap` or `LiveCounter`) by its object ID |
348+
| **boolean** | A boolean leaf value |
349+
| **bytes** | A binary leaf value (`ArrayBuffer` in browser environments, or `Buffer` in Node.js) |
350+
| **number** | A numeric leaf value |
351+
| **string** | A string leaf value |
352+
| **json** | A parsed JSON object or array leaf value |
347353

348354
</If>

src/pages/docs/liveobjects/concepts/path-object.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,15 +536,15 @@ When subscribed to a `LiveMap`, the `object` passed to the subscription is a `Pa
536536
// Subscribe to a LiveCounter stored in 'visits'
537537
const visits = myObject.get('visits');
538538
visits.subscribe(({ object, message }) => {
539-
console.log('path:', object.path(), 'amount:', message?.operation?.counterOp?.amount);
539+
console.log('path:', object.path(), 'number:', message?.operation?.counterInc?.number);
540540
});
541541
await visits.increment(5);
542-
// path: visits amount: 5
542+
// path: visits number: 5
543543

544544
// Subscribe to a LiveMap stored in 'settings'
545545
const settings = myObject.get('settings');
546546
settings.subscribe(({ object, message }) => {
547-
console.log('path:', object.path(), 'key:', message?.operation?.mapOp?.key);
547+
console.log('path:', object.path(), 'key:', message?.operation?.mapSet?.key);
548548
});
549549
await settings.set('theme', 'dark');
550550
// path: settings key: theme
@@ -555,7 +555,7 @@ await settings.get('preferences').set('language', 'en');
555555
const settings = myObject.get('settings');
556556
const theme = settings.get('theme');
557557
theme.subscribe(({ object, message }) => {
558-
console.log('path:', object.path(), 'key:', message?.operation?.mapOp?.key);
558+
console.log('path:', object.path(), 'key:', message?.operation?.mapSet?.key);
559559
});
560560
await settings.set('theme', 'dark');
561561
// path: settings.theme key: theme

0 commit comments

Comments
 (0)