Skip to content
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

[PUB-1039] Update Live Objects README section #1969

Open
wants to merge 1 commit into
base: integration/liveobjects
Choose a base branch
from

Conversation

VeskeR
Copy link
Contributor

@VeskeR VeskeR commented Feb 13, 2025

Describe the Live Objects create/edit/read API, live object types, root object, state channel modes, batch operations lifecycle events and user provided typings for Live Objects.

Resolves PUB-1039

Summary by CodeRabbit

  • Documentation
    • Enhanced Ably client library documentation with refined guidance on push notifications and LiveObjects.
    • Corrected a typographical error in the push notifications text.
    • Renamed the Live Objects section to "LiveObjects" and added a new "State Channel Modes" subsection detailing channel requirements.
    • Updated example code to TypeScript, offering clearer instructions for interacting with LiveObjects features such as LiveMap and LiveCounter.
    • Expanded explanations for LiveObjects types with detailed usage instructions and examples.

Copy link

coderabbitai bot commented Feb 13, 2025

Walkthrough

The documentation in the README.md has been updated to improve clarity around the Ably client library’s LiveObjects feature. A typo in "push notifications" has been corrected, and the section formerly titled "Live Objects functionality" is now simply "LiveObjects." A new "State Channel Modes" subsection has been added, and the code examples have been updated from JavaScript to TypeScript. Detailed explanations, including how to initialize the client and work with LiveMap and LiveCounter, have been incorporated. Additionally, the ably.d.ts file has standardized terminology by renaming "Live Objects" to "LiveObjects" in relevant comments.

Changes

File Path Change Summary
README.md - Corrected typo in "push notifications".
- Renamed "Live Objects functionality" to "LiveObjects".
- Added "State Channel Modes" subsection with channel mode details.
- Updated code snippets from JavaScript to TypeScript and refined examples for LiveMap and LiveCounter.
ably.d.ts - Updated comments to replace "Live Objects" with "LiveObjects" in LiveObjectsEvents and LiveObjectLifecycleEvents namespaces, standardizing terminology.

Possibly related PRs

Suggested reviewers

  • zknill
  • kaschula

Poem

In the garden of docs, I happily roam,
Hoping through guidelines to make code my home,
With a corrected typo and TypeScript in sight,
LiveObjects shine clearly, so brilliantly bright,
I, a rabbit, cheer with a skip and a hop,
Enjoying these changes that never shall stop! 🐰🌸


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@VeskeR VeskeR requested review from zknill and kaschula February 13, 2025 09:28
@github-actions github-actions bot temporarily deployed to staging/pull/1969/bundle-report February 13, 2025 09:29 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1969/typedoc February 13, 2025 09:29 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1969/features February 13, 2025 09:29 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
README.md (3)

626-645: Consider adding examples of required capabilities.

The State Channel Modes section clearly explains the required channel modes. However, it would be helpful to include examples of the corresponding capabilities required in the authentication token.

Add examples of required capabilities:

+```typescript
+// Example capabilities for Live Objects
+{
+  "channel": {
+    "my_live_objects_channel": ["state_subscribe", "state_publish"]
+  }
+}
+```
🧰 Tools
🪛 LanguageTool

[uncategorized] ~628-~628: Possible missing article found.
Context: ...cts). #### State Channel Modes To use Live Objects feature, clients must attach to...

(AI_HYDRA_LEO_MISSING_THE)

🪛 markdownlint-cli2 (0.17.2)

633-633: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


707-756: Consider adding error handling examples.

The Subscribing to Updates section is well-documented, but it would be beneficial to include examples of error handling in the subscription callbacks.

Add error handling examples:

+```typescript
+// Example with error handling
+root.subscribe((update: LiveMapUpdate) => {
+  try {
+    console.log('LiveMap updated:', update);
+    // Handle the update
+  } catch (error) {
+    console.error('Error handling LiveMap update:', error);
+  }
+});
+```
🧰 Tools
🪛 LanguageTool

[uncategorized] ~708-~708: It seems likely that a singular genitive (’s) apostrophe is missing.
Context: ...ltiple clients may modify the same Live Objects state, subscribing ensures that your ap...

(AI_HYDRA_LEO_APOSTROPHE_S_XS)

🪛 markdownlint-cli2 (0.17.2)

714-714: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


744-744: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


785-805: Consider adding error handling for batch operations.

The Batch Operations section clearly explains batching, but should include guidance on error handling within batch callbacks.

Add error handling example:

+```typescript
+// Example with error handling
+try {
+  await liveObjects.batch((ctx) => {
+    // ... batch operations
+  });
+} catch (error) {
+  console.error('Batch operation failed:', error);
+  // Handle the error appropriately
+}
+```
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

791-791: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6fc1702 and 344c5e9.

📒 Files selected for processing (1)
  • README.md (3 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md

[style] ~593-~593: Consider a shorter alternative to avoid wordiness.
Context: ...ime clients via the LiveObjects plugin. In order to use Live Objects, you must pass in the ...

(IN_ORDER_TO_PREMIUM)


[uncategorized] ~628-~628: Possible missing article found.
Context: ...cts). #### State Channel Modes To use Live Objects feature, clients must attach to...

(AI_HYDRA_LEO_MISSING_THE)


[style] ~648-~648: Consider a shorter alternative to avoid wordiness.
Context: ...d data structures and must be retrieved in order to interact with the existing state. ```t...

(IN_ORDER_TO_PREMIUM)


[uncategorized] ~708-~708: It seems likely that a singular genitive (’s) apostrophe is missing.
Context: ...ltiple clients may modify the same Live Objects state, subscribing ensures that your ap...

(AI_HYDRA_LEO_APOSTROPHE_S_XS)

🪛 markdownlint-cli2 (0.17.2)
README.md

595-595: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


615-615: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


633-633: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


650-650: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


664-664: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


692-692: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


714-714: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


744-744: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


762-762: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


769-769: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


791-791: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


813-813: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


827-827: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


839-839: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


858-858: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


878-878: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


888-888: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)

🪛 GitHub Actions: Lint
README.md

[warning] 1-1: Code style issues found in the above file. Run Prettier with --write to fix.

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: test-node (20.x)
  • GitHub Check: test-browser (webkit)
  • GitHub Check: test-node (18.x)
  • GitHub Check: test-browser (firefox)
  • GitHub Check: test-browser (chromium)
  • GitHub Check: test-node (16.x)
  • GitHub Check: test-npm-package
🔇 Additional comments (7)
README.md (7)

587-587: LGTM!

Good addition of the link to push notifications documentation, which helps users find more detailed information.


589-624: LGTM! Well-structured introduction to Live Objects.

The introduction and plugin usage section is clear and comprehensive, providing both npm and CDN installation options with proper versioning information.

🧰 Tools
🪛 LanguageTool

[style] ~593-~593: Consider a shorter alternative to avoid wordiness.
Context: ...ime clients via the LiveObjects plugin. In order to use Live Objects, you must pass in the ...

(IN_ORDER_TO_PREMIUM)


[uncategorized] ~622-~622: Possible missing comma found.
Context: ...y.com/lib/liveobjects.umd.min-2.4.0.js. Note you can load the non-minified version b...

(AI_HYDRA_LEO_MISSING_COMMA)

🪛 markdownlint-cli2 (0.17.2)

595-595: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


609-609: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


615-615: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


622-622: Bare URL used
null

(MD034, no-bare-urls)


622-622: Bare URL used
null

(MD034, no-bare-urls)


622-622: Bare URL used
null

(MD034, no-bare-urls)


622-622: Bare URL used
null

(MD034, no-bare-urls)


622-622: Spaces inside emphasis markers
null

(MD037, no-space-in-emphasis)


647-655: LGTM! Clear explanation of the root object.

The Root Object section effectively explains its role as the entry point for Live Objects state.

🧰 Tools
🪛 LanguageTool

[style] ~648-~648: Consider a shorter alternative to avoid wordiness.
Context: ...d data structures and must be retrieved in order to interact with the existing state. ```t...

(IN_ORDER_TO_PREMIUM)

🪛 markdownlint-cli2 (0.17.2)

650-650: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


657-705: LGTM! Comprehensive coverage of Live Object Types.

The Live Object Types section provides clear explanations and examples for both LiveMap and LiveCounter types.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

664-664: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


692-692: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


758-783: LGTM! Clear examples of object creation and hierarchy.

The Creating New Objects section effectively demonstrates how to create and organize Live Objects in a hierarchy.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

762-762: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


769-769: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


807-852: LGTM! Comprehensive coverage of lifecycle events.

The Lifecycle Events section effectively explains both synchronization and deletion events with clear examples.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

813-813: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


827-827: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


839-839: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


854-885: LGTM! Well-documented TypeScript support.

The Typing Live Objects section provides clear examples of both global and channel-specific type definitions.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

858-858: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


878-878: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)

README.md Outdated

#### Live Object Types

Live Objects support two primary data structures:
Copy link
Member

Choose a reason for hiding this comment

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

currently

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated 👍

@VeskeR VeskeR force-pushed the PUB-1039/update-readme branch from 344c5e9 to cf1c49b Compare February 13, 2025 09:34
@github-actions github-actions bot temporarily deployed to staging/pull/1969/bundle-report February 13, 2025 09:35 Inactive
@VeskeR VeskeR force-pushed the PUB-1039/update-readme branch from cf1c49b to 54a5125 Compare February 13, 2025 09:35
@github-actions github-actions bot temporarily deployed to staging/pull/1969/bundle-report February 13, 2025 09:36 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1969/features February 13, 2025 09:36 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1969/typedoc February 13, 2025 09:36 Inactive

Subscribing to updates on Live Objects allows you to receive changes made by other clients in realtime. Since multiple clients may modify the same Live Objects state, subscribing ensures that your application reacts to external updates as soon as they are received.

Additionally, mutation methods such as `LiveMap.set`, `LiveCounter.increment`, and `LiveCounter.decrement` do not directly edit the current state of the object locally. Instead, they send the intended operation to the Ably system, and the change is applied to the local object only when the corresponding realtime operation is echoed back to the client. This means that the state you retrieve immediately after a mutation may not reflect the latest updates yet.
Copy link
Member

Choose a reason for hiding this comment

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

Can you clarify this? If you await a mutation, the local state does not have that mutation applied after completion of the operation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, the mutation operation might not be applied after we await the mutation call, as this only awaits the ACK message for the mutation operation. It will be applied only once the operation is echoed back to the client.

We discussed this with Mike in this DR, and considered the possibility of applying the mutation client-side when we receive an ACK message (meaning it would be applied locally after await). It needed more thought (as we rely on applying messages from a given site in regional order), and it was put on hold for the time being.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The current behaviour is consistent with that of presence in the core SDKs, right? e.g. if you call presence.get() immediately after the completion of presence.enter(), you might not see yourself in the presence set.

@VeskeR VeskeR requested a review from a team February 13, 2025 13:49
README.md Outdated

The authentication token must include corresponding capabilities for the client to interact with Live Objects.

#### Obtaining the Root Object
Copy link

Choose a reason for hiding this comment

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

Obtaining is a really convoluted word. Where possible we should prefer the simplest possible language. How about "getting" or "accessing" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

README.md Outdated

#### Obtaining the Root Object

The root object represents the top-level entry point for Live Objects state within a channel. It acts as a container for all nested data structures and must be retrieved in order to interact with the existing state.
Copy link

@zknill zknill Feb 14, 2025

Choose a reason for hiding this comment

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

Suggested change
The root object represents the top-level entry point for Live Objects state within a channel. It acts as a container for all nested data structures and must be retrieved in order to interact with the existing state.
The root object represents the top-level entry point for Live Objects state within a channel. It give access to all other nested live objects.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link

@zknill zknill left a comment

Choose a reason for hiding this comment

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

Nice! A few boring re-word suggestions for simplicity/clarity 👌

README.md Outdated
const root = await liveObjects.getRoot();
```

The root object is always a `LiveMap` instance and serves as the starting point for storing and organizing Live Objects state.
Copy link

Choose a reason for hiding this comment

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

Suggested change
The root object is always a `LiveMap` instance and serves as the starting point for storing and organizing Live Objects state.
The root object is a `LiveMap` instance and serves as the starting point for storing and organizing Live Objects state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

README.md Outdated

#### Live Object Types

Live Objects currently support two primary data structures:
Copy link

Choose a reason for hiding this comment

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

Suggested change
Live Objects currently support two primary data structures:
Live Objects currently supports two primary data structures; LiveMap and LiveCounter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

README.md Outdated

Additionally, mutation methods such as `LiveMap.set`, `LiveCounter.increment`, and `LiveCounter.decrement` do not directly edit the current state of the object locally. Instead, they send the intended operation to the Ably system, and the change is applied to the local object only when the corresponding realtime operation is echoed back to the client. This means that the state you retrieve immediately after a mutation may not reflect the latest updates yet.

To ensure you react to state changes at the correct moment, you can subscribe to updates on all Live Objects as follows:
Copy link

Choose a reason for hiding this comment

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

Suggested change
To ensure you react to state changes at the correct moment, you can subscribe to updates on all Live Objects as follows:
You can subscribe to updates on all Live Objects using subscription listeners as follows:

I've added "subscription listeners" here because later way say you can de-register "subscription listeners" without mentioning them before. Obviously you can see from the code, but adding clarity here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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


// perform operations on LiveMap and LiveCounter
await root.set('name', 'Alice');
// LiveMap updated: { update: { name: 'updated' } }
Copy link

Choose a reason for hiding this comment

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

question: should the update event carry the new value as well as the key that was modified?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the current API only exposes the name of the key that got updated/deleted. it is trivial at this point to just call root.get(key) to get the new value.

a bit more useful could be exposing both the previous and teh new value, just like we do with ChannelStateChange, but currently it's not implemented

Copy link
Contributor Author

Choose a reason for hiding this comment

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

README.md Outdated
});
```

**Object Deletion Events** - objects that have been orphaned for a long period (i.e., not connected to the state tree graph by being set as a key in a map related to the root) will eventually be deleted. Once a Live Object is deleted, it can no longer be interacted with. You should avoid accessing its data or try to update its value and should remove all references to the deleted object in your application.
Copy link

Choose a reason for hiding this comment

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

Suggested change
**Object Deletion Events** - objects that have been orphaned for a long period (i.e., not connected to the state tree graph by being set as a key in a map related to the root) will eventually be deleted. Once a Live Object is deleted, it can no longer be interacted with. You should avoid accessing its data or try to update its value and should remove all references to the deleted object in your application.
**Object Deletion Events** - objects that have been orphaned for a long period (i.e., not connected to the state tree graph by being set as a key in a map related to the root) will eventually be deleted. Once a Live Object is deleted, it can no longer be interacted with. You should avoid accessing its data or trying to update its value and you should remove all references to the deleted object in your application.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also maybe related to the root -> accessible from the root map object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@mschristensen mschristensen left a comment

Choose a reason for hiding this comment

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

Great stuff, thanks Andrii - just a couple of comments

README.md Outdated

#### State Channel Modes

To use Live Objects feature, clients must attach to a channel with the correct channel mode:
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we calling it Live Objects or LiveObjects? I think we should use a consistent name, so probably LiveObjects

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, it's the LiveObjects product, but sometimes the readme explicitly refers to the objects in LiveObjects, which are just Live Objects.
I've gone through all of the "liveobjects"/"live objects" uses to double check which they are referring to and update accordingly:
https://github.com/ably/ably-js/compare/54a5125fcd43b43948ca982f7a1ed89c538cec50..3ca50035284754bf9cac21af0de744a0ae97ef85
https://github.com/ably/ably-js/compare/3ca50035284754bf9cac21af0de744a0ae97ef85..2065e11c8b39e421b3289cad832930814d03a618

README.md Outdated
await root.set('qux', new Uint8Array([21, 31]));
// as well as other live objects
const counter = await liveObjects.createCounter();
await root.get('quux', counter);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be root.set ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

README.md Outdated

#### Batch Operations

Batching allows multiple operations to be grouped into a single message that is sent to the Ably service.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Batching allows multiple operations to be grouped into a single message that is sent to the Ably service.
Batching allows multiple operations to be grouped into a single message that is sent to the Ably service. This allows batched operations to be applied atomically together.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

README.md Outdated
});
```

**Object Deletion Events** - objects that have been orphaned for a long period (i.e., not connected to the state tree graph by being set as a key in a map related to the root) will eventually be deleted. Once a Live Object is deleted, it can no longer be interacted with. You should avoid accessing its data or try to update its value and should remove all references to the deleted object in your application.
Copy link
Contributor

Choose a reason for hiding this comment

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

Also maybe related to the root -> accessible from the root map object.

README.md Outdated
}
```

This will enable IntelliSense support when interacting with the Live Objects API:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think IntelliSense is a microsoft-specific concept, perhaps code completion and editor hints ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@VeskeR VeskeR requested review from paddybyers and zknill February 18, 2025 09:29
@VeskeR VeskeR force-pushed the PUB-1039/update-readme branch from 54a5125 to 3ca5003 Compare February 18, 2025 09:54
@github-actions github-actions bot temporarily deployed to staging/pull/1969/features February 18, 2025 09:55 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1969/typedoc February 18, 2025 09:55 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1969/bundle-report February 18, 2025 09:55 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (5)
README.md (5)

591-594: Using the LiveObjects Plugin – Wording Suggestion
The description in this block is clear; however, the sentence “In order to use LiveObjects, you must pass in the plugin via client options.” can be made more concise. Consider rephrasing it as, for example:

  • “To use LiveObjects, include the plugin in your client options.”
    This improves readability without losing meaning.
-LiveObjects functionality is supported for Realtime clients via the LiveObjects plugin. In order to use LiveObjects, you must pass in the plugin via client options.
+LiveObjects functionality is supported for Realtime clients via the LiveObjects plugin. To use LiveObjects, include the plugin in your client options.
🧰 Tools
🪛 LanguageTool

[style] ~593-~593: Consider a shorter alternative to avoid wordiness.
Context: ...ime clients via the LiveObjects plugin. In order to use LiveObjects, you must pass in the p...

(IN_ORDER_TO_PREMIUM)


646-650: Getting the Root Object – Clarity and Terminology
The “#### Getting the Root Object” section explains the purpose clearly.
Suggestion: Instead of “gives access to all other nested Live Objects,” consider “provides access to all other nested Live Objects” to improve clarity.

-The root object represents the top-level entry point for LiveObjects state within a channel. It gives access to all other nested Live Objects.
+The root object represents the top-level entry point for LiveObjects state within a channel. It provides access to all nested Live Objects.
🧰 Tools
🪛 LanguageTool

[style] ~648-~648: Try using a synonym here to strengthen your writing.
Context: ... LiveObjects state within a channel. It gives access to all other nested Live Objects...

(GIVE_PROVIDE)

🪛 markdownlint-cli2 (0.17.2)

650-650: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


707-714: Subscribing to Updates – Description and Guidance
The introduction to subscription updates is mostly clear. Note that one of the static analysis hints suggested that the sentence may be missing an apostrophe in a possessive form. Please double-check for minor grammatical correctness (e.g. “clients’ updates” if applicable). Overall, the explanation is helpful.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~709-~709: It seems likely that a singular genitive (’s) apostrophe is missing.
Context: ...ltiple clients may modify the same Live Objects state, subscribing ensures that your ap...

(AI_HYDRA_LEO_APOSTROPHE_S_XS)


826-834: Object Deletion Events – Grammar and Clarity
The explanation for deletion events is comprehensive.
Suggestion: Consider adding a comma before “and you should remove all references…” for better readability.

-Once a Live Object is deleted, it can no longer be interacted with. You should avoid accessing its data or trying to update its value and you should remove all references to the deleted object in your application.
+Once a Live Object is deleted, it can no longer be interacted with. You should avoid accessing its data or trying to update its value, and you should remove all references to the deleted object in your application.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~826-~826: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...g its data or trying to update its value and you should remove all references to the...

(COMMA_COMPOUND_SENTENCE)

🪛 markdownlint-cli2 (0.17.2)

828-828: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


595-595: Markdown Code Block Style Consistency
Several static analysis hints indicate a preference for indented code blocks over fenced code blocks in these regions. Although many teams favor fenced code blocks for clarity, please confirm that this style conforms to the project’s markdown guidelines. If a change is necessary, consider adjusting the code block style as recommended by markdownlint.

Also applies to: 615-615, 633-633, 650-650, 664-664, 693-693, 715-715, 745-745, 763-763, 770-770, 792-792, 814-814, 828-828, 840-840, 859-859, 879-879, 889-889

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

595-595: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 344c5e9 and 3ca5003.

📒 Files selected for processing (1)
  • README.md (3 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md

[style] ~593-~593: Consider a shorter alternative to avoid wordiness.
Context: ...ime clients via the LiveObjects plugin. In order to use LiveObjects, you must pass in the p...

(IN_ORDER_TO_PREMIUM)


[style] ~648-~648: Try using a synonym here to strengthen your writing.
Context: ... LiveObjects state within a channel. It gives access to all other nested Live Objects...

(GIVE_PROVIDE)


[uncategorized] ~709-~709: It seems likely that a singular genitive (’s) apostrophe is missing.
Context: ...ltiple clients may modify the same Live Objects state, subscribing ensures that your ap...

(AI_HYDRA_LEO_APOSTROPHE_S_XS)


[uncategorized] ~812-~812: It seems likely that a singular genitive (’s) apostrophe is missing.
Context: ...nd synced events notify when the Live Objects state is being synchronized with the Ab...

(AI_HYDRA_LEO_APOSTROPHE_S_XS)


[uncategorized] ~826-~826: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...g its data or trying to update its value and you should remove all references to the...

(COMMA_COMPOUND_SENTENCE)

🪛 markdownlint-cli2 (0.17.2)
README.md

595-595: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


615-615: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


633-633: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


650-650: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


664-664: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


693-693: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


715-715: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


745-745: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


763-763: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


770-770: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


792-792: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


814-814: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


828-828: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


840-840: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


859-859: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


879-879: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


889-889: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: test-node (20.x)
  • GitHub Check: test-browser (webkit)
  • GitHub Check: test-node (18.x)
  • GitHub Check: test-browser (firefox)
  • GitHub Check: test-node (16.x)
  • GitHub Check: test-browser (chromium)
  • GitHub Check: test-npm-package
🔇 Additional comments (22)
README.md (22)

587-588: External Reference for Push Notifications Documentation
The link and short description for more information on publishing push notifications look correct and clear.


589-590: Section Title Update to “LiveObjects”
The new “### LiveObjects” header clearly distinguishes this section. The consistency with other documentation now improves.


595-603: TypeScript Example: Import and Initialization of LiveObjects (Module Import)
The code snippet demonstrating how to import and initialize the LiveObjects plugin using TypeScript is well written and follows best practices.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

595-595: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


610-612: HTML Example for Loading the LiveObjects Plugin
The HTML code snippet for loading the LiveObjects plugin via a <script> tag is clear and correct.


615-620: TypeScript Example: Global Plugin Usage for LiveObjects
This snippet correctly demonstrates how to use the global AblyLiveObjectsPlugin when loading the plugin via a script tag. It clearly shows the alternative initialization approach.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

615-615: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


624-625: Product Documentation Link for LiveObjects
The reference link for further information on the LiveObjects product is appropriate.


626-630: State Channel Modes Explanation
The “#### State Channel Modes” section correctly enumerates the required channel modes (state_subscribe and state_publish). The list is informative and precise.


633-642: Code Example: Attaching Channel Modes for LiveObjects
The TypeScript code snippet that demonstrates setting channel options with the required modes is clear and effective.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

633-633: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


644-645: Clarification on Authentication Requirements
The note emphasizing that the authentication token must include corresponding capabilities is concise and clear.


656-660: Introduction to Live Object Types
The brief introduction describing that LiveObjects supports two primary data structures (LiveMap and LiveCounter) is concise and informative.


662-687: LiveMap Usage Example
The code example for using a LiveMap (setting, getting, and removing keys) is clear and includes diverse operations. The inline comments help clarify the output expectations.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

664-664: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


691-705: LiveCounter Usage Example
The LiveCounter example demonstrates initialization, incrementing, and decrementing, along with expected outputs. The snippet is accurate and well documented.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

693-693: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


716-727: Code Example: Updating Subscription on Live Objects
The TypeScript code that subscribes to updates on both a LiveMap and a LiveCounter works as intended and documents the expected console outputs effectively.


743-751: Deregistering Subscription Listeners
The provided examples showing both the dedicated unsubscribe function and passing a listener reference are clear and useful for developers.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

745-745: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


759-767: Creating New Live Objects
The “#### Creating New Objects” section along with the accompanying TypeScript snippet clearly demonstrates how to create a LiveCounter and a LiveMap with optional initial values.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

763-763: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


767-774: Persisting Live Objects in State
The instructions for persisting new objects by assigning them to a parent LiveMap are clear. The structured code snippet makes the object hierarchy easy to understand.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

770-770: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


786-800: Batch Operations Example
The batch operation snippet is well presented. It clearly shows how to group operations atomically using a batch callback and then verifies the results.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

792-792: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


808-820: Lifecycle Events: Synchronization Notifications
This section clearly explains the purpose of syncing and synced events and provides a concise TypeScript example.
Note: One of the static hints mentioned a potential apostrophe issue; consider ensuring possessives (if needed) are formatted correctly.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~812-~812: It seems likely that a singular genitive (’s) apostrophe is missing.
Context: ...nd synced events notify when the Live Objects state is being synchronized with the Ab...

(AI_HYDRA_LEO_APOSTROPHE_S_XS)

🪛 markdownlint-cli2 (0.17.2)

814-814: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


838-848: Unsubscribing from Lifecycle Events
The TypeScript snippet demonstrating how to unregister lifecycle event listeners (using both a destructured off function and passing a listener reference) is clear and instructive.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

840-840: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


855-871: Providing Custom TypeScript Typings for LiveObjects
The instructions and example for providing custom typings via the global LiveObjectsTypes interface are well structured and useful for enabling improved code completion.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

859-859: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


877-883: Example: Enabling Code Completion with Custom Typings
This snippet accurately demonstrates how the globally declared types influence code completion. The inline comment about the TypeError is a helpful indicator for type safety.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

879-879: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


886-897: Multiple Typings for Different LiveObjects State Trees
The example showing how to supply different state typings for different channels is clear and valuable for advanced use cases.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

889-889: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)

Describe the Live Objects create/edit/read API, live object types,
root object, state channel modes, batch operations lifecycle events and
user provided typings for Live Objects.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
README.md (2)

646-650: Document how to obtain the root LiveObjects object.
The “#### Getting the Root Object” section introduces the concept clearly. Nitpick: Consider rewording “gives access” to “provides access” for a slightly more formal tone.

🧰 Tools
🪛 LanguageTool

[style] ~648-~648: Try using a synonym here to strengthen your writing.
Context: ... LiveObjects state within a channel. It gives access to all other nested Live Objects...

(GIVE_PROVIDE)

🪛 markdownlint-cli2 (0.17.2)

650-650: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


826-836: Explain object deletion events and adjust punctuation for clarity.
The “Object Deletion Events” description explains that orphaned LiveObjects will eventually be deleted and emphasizes that applications should not access them thereafter.
Nitpick: Consider adding a comma before “and you should remove all references…” for improved clarity.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~826-~826: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...g its data or trying to update its value and you should remove all references to the...

(COMMA_COMPOUND_SENTENCE)

🪛 markdownlint-cli2 (0.17.2)

828-828: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ca5003 and 2065e11.

📒 Files selected for processing (2)
  • README.md (3 hunks)
  • ably.d.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • ably.d.ts
🧰 Additional context used
🪛 LanguageTool
README.md

[style] ~593-~593: Consider a shorter alternative to avoid wordiness.
Context: ...ime clients via the LiveObjects plugin. In order to use LiveObjects, you must pass in the p...

(IN_ORDER_TO_PREMIUM)


[style] ~648-~648: Try using a synonym here to strengthen your writing.
Context: ... LiveObjects state within a channel. It gives access to all other nested Live Objects...

(GIVE_PROVIDE)


[uncategorized] ~826-~826: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...g its data or trying to update its value and you should remove all references to the...

(COMMA_COMPOUND_SENTENCE)

🪛 markdownlint-cli2 (0.17.2)
README.md

595-595: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


615-615: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


633-633: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


650-650: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


664-664: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


693-693: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


715-715: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


745-745: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


763-763: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


770-770: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


792-792: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


814-814: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


828-828: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


840-840: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


859-859: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


879-879: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


889-889: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: test-browser (webkit)
  • GitHub Check: test-node (20.x)
  • GitHub Check: test-browser (firefox)
  • GitHub Check: test-node (18.x)
  • GitHub Check: test-npm-package
  • GitHub Check: test-node (16.x)
  • GitHub Check: test-browser (chromium)
🔇 Additional comments (18)
README.md (18)

587-587: Add reference to push notifications documentation.
The additional line clarifies where users can learn more about publishing push notifications over Ably. This is a useful pointer in the push notifications section.


589-594: Introduce and label the LiveObjects section.
The new “### LiveObjects” header with the subsequent “#### Using the plugin” subheading clearly marks the beginning of the LiveObjects documentation. This improves the structure and discoverability of the new feature documentation.

🧰 Tools
🪛 LanguageTool

[style] ~593-~593: Consider a shorter alternative to avoid wordiness.
Context: ...ime clients via the LiveObjects plugin. In order to use LiveObjects, you must pass in the p...

(IN_ORDER_TO_PREMIUM)


595-603: Correctly demonstrate LiveObjects plugin usage in TypeScript.
The code snippet importing LiveObjects from 'ably/liveobjects' and initializing the Ably client with plugins: { LiveObjects } is well presented and consistent with TypeScript usage.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

595-595: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


604-606: Clarify support for the modular variant.
The statement that “LiveObjects plugin also works with the [Modular variant]” is concise and informs users about multiple integration options.


607-611: Provide an HTML-based loading example for the LiveObjects plugin.
The HTML snippet for loading the LiveObjects plugin via a <script> tag is clear. Consider verifying that the referenced URL (https://cdn.ably.com/lib/liveobjects.umd.min-2.js) is up-to-date with your release strategy.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

609-609: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


612-619: Demonstrate usage of the global LiveObjects plugin.
The TypeScript snippet showing how to initialize the client using the global AblyLiveObjectsPlugin (i.e. passing { LiveObjects: AblyLiveObjectsPlugin }) is correct. This helps users who load the plugin via a <script> tag.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

615-615: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


626-632: Explain the required channel modes for LiveObjects.
The “#### State Channel Modes” section and the accompanying list (with state_subscribe and state_publish) clearly explain the necessary channel modes. This is important for ensuring that clients attach with the correct permissions.


633-642: Show channel initialization with state channel modes.
The code snippet initializing the client with state channel modes is well formatted and instructive. It demonstrates how to pass channel options for enabling LiveObjects features.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

633-633: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


654-654: State the type of the root object.
The note that “The root object is a LiveMap instance…” succinctly informs users of the underlying type, which is helpful for further usage.


656-664: Detail LiveObjects’ primary data structures with a LiveMap example.
The “#### Live Object Types” section along with the LiveMap usage code snippet is clear and comprehensive. The snippet demonstrates setting, getting, and removing keys as well as handling various data types—including nesting another live object.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

664-664: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


688-694: Demonstrate LiveCounter usage.
The LiveCounter example clarifies how to create a counter and perform basic operations (incrementing and decrementing). The concise example provides immediate clarity on its behavior.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

693-693: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


706-715: Explain subscription to updates for LiveObjects.
The “#### Subscribing to Updates” section and its code snippet clearly illustrate how to subscribe to updates on both LiveMap and LiveCounter. This section effectively demonstrates the concept of real‑time change propagation.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

715-715: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


742-745: Show how to deregister subscription listeners.
The provided code snippet for unsubscribing from update events (using both a dedicated unsubscribe function and the listener reference) is straightforward and instructive.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

745-745: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


758-767: Introduce creation of new LiveObjects.
The “#### Creating New Objects” section and accompanying snippet clearly explain how to instantiate new LiveMap and LiveCounter objects. This new section aligns well with the rest of the documentation.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

763-763: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


767-776: Illustrate how to persist new objects within the LiveObjects state tree.
The snippet showing how to assign newly created objects to a parent LiveMap (thereby integrating them into the hierarchy) is helpful. The visual structure comment further reinforces understanding.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

770-770: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


807-818: Demonstrate handling of synchronization lifecycle events.
The “#### Lifecycle Events” section shows how to subscribe to syncing and synced events. This example is clear and helps developers understand how to hook into synchronization state changes to, for example, manage loading indicators.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

814-814: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


839-853: Show how to unsubscribe from lifecycle events.
The unsubscribe snippet demonstrates both the dedicated off function and the usage of passing a listener reference. This provides clear guidance on how to clean up event handlers.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

840-840: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


854-902: Provide comprehensive TypeScript typings for LiveObjects.
The “#### Typing LiveObjects” section—including the global declaration in ably.config.d.ts and the examples showing both the default type usage and generic usage with getRoot—enhances developer experience by enabling code completion and type safety. All examples are thorough and clearly documented.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

859-859: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


879-879: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)


889-889: Code block style
Expected: indented; Actual: fenced

(MD046, code-block-style)

README.md Show resolved Hide resolved
@VeskeR VeskeR requested a review from mschristensen February 18, 2025 10:07
// set a key on map
await root.set('name', 'Alice');
// get a value for a key
console.log(root.get('name')); // output: 'Alice'
Copy link
Collaborator

@lawrence-forooghian lawrence-forooghian Feb 18, 2025

Choose a reason for hiding this comment

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

I get the point that we're trying to make in demonstrating this API, but it might be a bit misleading or confusing given that, as you say later, updates are not immediately reflected in the local state.

const root = await liveObjects.getRoot();

// subscribe to updates on a LiveMap
root.subscribe((update: LiveMapUpdate) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we could make it clearer that the user does not need to look at the contents of the update; i.e. that they can just re-read the entire LiveMap or LiveCounter if they wish?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants