Skip to content

[PUB-1667] Update LiveObjects docs to reflect support for JSON-serializable objects as LiveMap values #2689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pages/docs/liveobjects/concepts/objects.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ LiveObjects provides specialized object types to model your application state. T
[LiveMap](/docs/liveobjects/map) is a key/value data structure similar to a dictionary or JavaScript [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map):

* Keys must be strings
* Values can be primitive types or [references](#composability) to other objects
* Values can be primitive types, JSON-serializable objects or arrays, or [references](#composability) to other objects
* Supports `set` and `remove` operations
* Concurrent updates to the same key are resolved using last-write-wins (LWW) semantics

Expand Down
2 changes: 1 addition & 1 deletion src/pages/docs/liveobjects/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ LiveObjects provides specialized object types to model your application state. T

#### LiveMap <a id="map"/>

[LiveMap](/docs/liveobjects/map) is a key/value data structure that synchronizes its state across users in realtime. It enables you to store primitive values, such as numbers, strings, booleans and buffers, as well as other objects, enabling [composable data structures](#composability).
[LiveMap](/docs/liveobjects/map) is a key/value data structure that synchronizes its state across users in realtime. It enables you to store primitive values, such as numbers, strings, booleans and buffers; JSON-serializable objects or arrays; and other LiveObjects types, enabling [composable data structures](#composability).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would drop the semicolons and stick consistently with commas

Suggested change
[LiveMap](/docs/liveobjects/map) is a key/value data structure that synchronizes its state across users in realtime. It enables you to store primitive values, such as numbers, strings, booleans and buffers; JSON-serializable objects or arrays; and other LiveObjects types, enabling [composable data structures](#composability).
[LiveMap](/docs/liveobjects/map) is a key/value data structure that synchronizes its state across users in realtime. It enables you to store primitive values, such as numbers, strings, booleans, buffers, JSON-serializable objects or arrays and other LiveObjects types, enabling [composable data structures](#composability).

Applies to other files too


### Composability <a id="composability"/>

Expand Down
4 changes: 2 additions & 2 deletions src/pages/docs/liveobjects/map.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LiveObjects is currently Experimental. Its features are still in development and
**Building with LiveObjects?** Help shape its future by [sharing your use case](https://44qpp.share.hsforms.com/2fZobHQA1ToyRfB9xqZYQmQ).
</Aside>

LiveMap is a key/value data structure that synchronizes its state across users in realtime. It enables you to store primitive values, such as numbers, strings, booleans and buffers, as well as other objects, [enabling you to build complex, hierarchical object structure](#composability).
LiveMap is a key/value data structure that synchronizes its state across users in realtime. It enables you to store primitive values, such as numbers, strings, booleans and buffers; JSON-serializable objects or arrays; and other LiveObjects types, [enabling you to build complex, hierarchical object structure](#composability).

Conflicts in a LiveMap are automatically resolved with last-write-wins (LWW) semantics. The latest received operation on a key will be applied to the LiveMap and broadcast to all clients.

Expand Down Expand Up @@ -120,7 +120,7 @@ map.unsubscribeAll();

Set a value for a key in a map by calling `LiveMap.set()`. This operation is synchronized across all clients and triggers data subscription callbacks for the map, including on the client making the request.

Keys in a map can contain numbers, strings, booleans and buffers, as well as other `LiveMap` and `LiveCounter` objects.
Keys in a map can contain numbers, strings, booleans and buffers; JSON-serializable objects or arrays; and other `LiveMap` and `LiveCounter` objects.

This operation is asynchronous, as the client sends the corresponding update operation to the Ably system and waits for acknowledgment of the successful map key update.

Expand Down
11 changes: 6 additions & 5 deletions src/pages/docs/liveobjects/rest-api-usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ The key in the `data` object indicates the type of the value:

<Code>
```json
{ "data": { "number" : 42 }}
{ "data": { "string" : "LiveObjects is awesome" }}
{ "data": { "boolean" : true }}
{ "data": { "bytes": "TGl2ZU9iamVjdHMgaXMgYXdlc29tZQo=" }}
{ "data": { "objectId": "counter:JbZYiHnw0ORAyzzLSQahVik31iBDL_ehJNpTEF3qwg8@1745828651669" }}
{ "data": { "number": 42 } }
{ "data": { "string": "LiveObjects is awesome" } }
{ "data": { "string": "{\"hello\":\"world\"}", "encoding": "json" } }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we include an array example?

{ "data": { "boolean": true } }
{ "data": { "bytes": "TGl2ZU9iamVjdHMgaXMgYXdlc29tZQo=" } }
{ "data": { "objectId": "counter:JbZYiHnw0ORAyzzLSQahVik31iBDL_ehJNpTEF3qwg8@1745828651669" } }
```
</Code>

Expand Down
1 change: 1 addition & 0 deletions src/pages/docs/liveobjects/storage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ The size of a `LiveMap` object is calculated as the sum of the length of all key
* `number` values are 8 bytes
* `boolean` values are 1 byte
* `bytes` values are the length of the byte array
* JSON-serializable object or array values are equal to the length of their corresponding JSON strings

The maximum allowed size of a single `LiveMap` object is the same as the [message size limit](/docs/pricing/limits#message) for your package. This is because objects are [synchronized](/docs/liveobjects/concepts/synchronization#client-objects) to the client as channel messages.

Expand Down