-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add explanation for initialRoot
usage in Documentation
#173
Conversation
WalkthroughThe documentation for the Yorkie JS SDK has been updated to include a new section on initializing the root of a Document. This section explains how to manage application data types using the Changes
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (4)
docs/js-sdk.mdx (4)
70-77
: Add resulting state comment for clarity.Consider adding a comment showing the resulting state after initialization to help readers understand the outcome.
await client.attach(doc, { initialRoot: { list: [1, 2, 3], counter: new yorkie.Counter(yorkie.IntType, 0), }, }); +// resulting state +// root = { +// list: [1, 2, 3], +// counter: 0 +// }
84-96
: Fix code indentation for consistency.The indentation in the code example should be consistent with other examples in the documentation.
-await client.attach(doc, { - initialRoot: { - list: [], - }, -}); +await client.attach(doc, { + initialRoot: { + list: [], + }, +}); -// Another client tries to attach with initialRoot option: -await client.attach(doc, { - initialRoot: { - list: [1, 2, 3], // this update will be discarded - counter: new yorkie.Counter(yorkie.IntType, 0), // this update will be applied - }, -}); +// Another client tries to attach with initialRoot option: +await client.attach(doc, { + initialRoot: { + list: [1, 2, 3], // this update will be discarded + counter: new yorkie.Counter(yorkie.IntType, 0), // this update will be applied + }, +});
105-106
: Consider expanding supported types information.The reference to supported types could be more specific by listing the primitive types that are supported.
-We support element types for Primitives, and [Custom CRDT types](/js-sdk/#custom-crdt-types/). +We support element types for Primitives (string, number, boolean, null), and [Custom CRDT types](/js-sdk/#custom-crdt-types/).
107-110
: Enhance warning with implications.The warning about local application could be clearer about its implications for application developers.
-Elements added by `initialRoot` are not sent to the server during the `attach` process. They are applied locally to the Document after push-pull during `attach`. +Elements added by `initialRoot` are not sent to the server during the `attach` process. They are applied locally to the Document after push-pull during `attach`. This means other clients will not receive these initial values until they explicitly attach to the document.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- docs/js-sdk.mdx (1 hunks)
🔇 Additional comments (1)
docs/js-sdk.mdx (1)
66-68
: LGTM! Clear and concise introduction.The introduction effectively explains the purpose of
initialRoot
and its relationship to managing application data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution.
What this PR does / why we need it?
This PR adds documentation to describe the new feature that allows setting initial values when attaching a document. This functionality was introduced in PR #986, enabling developers to initialize documents with specific values upon attachment.
Any background context you want to provide?
What are the relevant tickets?
Fixes #
Checklist
Summary by CodeRabbit
initialRoot
are applied locally and not sent to the server during the attach process.