Uh oh!
There was an error while loading. Please reload this page.
[AIT-1138] docs(liveobjects): JS sections for PathObject.instance() wrapping primitives (RTPO8f) - #3487
Conversation
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Updates the LiveObjects documentation to reflect the newer PathObject.instance() JavaScript behavior: it now returns an Instance wrapping any resolved value (including primitives), and returns undefined only when the path does not resolve.
Changes:
- Updated JS prose in
PathObjectandInstancedocs to match the new “wrap primitives” behavior (parity with Java). - Updated JavaScript examples to demonstrate primitive-backed
Instancebehavior (idisundefined, primitive exposed viavalue()), and added parity comments clarifying whenundefinedis returned. - Fixed a small grammar issue in
batch.mdx(“anPathObject” → “aPathObject”).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/pages/docs/liveobjects/concepts/path-object.mdx | Updates JS explanation and example to show primitives are wrapped in a read-only Instance, and undefined is only for missing paths. |
| src/pages/docs/liveobjects/concepts/objects.mdx | Adds a JS parity comment clarifying instance() returns undefined only when nothing exists at the path. |
| src/pages/docs/liveobjects/concepts/instance.mdx | Expands intro and JS wording to include primitive-backed instances; clarifies id behavior and adds parity comment in example. |
| src/pages/docs/liveobjects/batch.mdx | Fixes a minor article typo in prose. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
PathObject.instance() wrapping primitives (RTPO8f)PathObject.instance() wrapping primitives (RTPO8f)798b4e1 to
3dbb299CompareUh oh!
There was an error while loading. Please reload this page.
Fixes https://ably.atlassian.net/browse/AIT-1138
Summary
Updates the JavaScript sections of the LiveObjects docs to reflect the new
PathObject.instance()behaviour: it now returns anInstancewrapping any resolved value, whether aLiveObjector a primitive.undefinedis returned only when the path does not resolve.The Java sections were already updated for this behaviour; this PR brings the JavaScript sections into full parity with them.
Why
The spec deprecated
RTPO8d(primitive → undefined/null) in favour ofRTPO8f(primitive →Instancewrapping the primitive value), and ably-js has adopted the change. A primitive-backedInstanceis read-only: it has noidand exposes the primitive viavalue().PathObject#instancewraps primitives (RTPO8f) specification#504PathObject.instance()wraps primitives per RTPO8f ably-js#2260Changes
concepts/path-object.mdxinstance()returnsundefinedonly if the entry at the path does not exist; a primitive value is wrapped in a read-onlyInstance.instance()returningundefinedfor a primitive. It now demonstrates the new behaviour (idisundefined,value()returns the primitive) and shows thatundefinedis returned only for a nonexistent path, mirroring the adjacent Java example.concepts/instance.mdxinstance()returnsundefinedonly if nothing exists at the path, and wraps whatever value resolves there.Instancecan also wrap a primitive value; the previous intro describedInstancepurely as a reference to a LiveObject identified by its object ID, contradicting the behaviour documented further down the page.idgetter docs: on a primitive-backed instance,idreturnsundefined, because primitives have no object ID.// undefined only if nothing exists at the pathcode comment for parity with the equivalent Java example comment.concepts/objects.mdxinstance()example, mirroring the existing Java comment.batch.mdxPathObject" → "aPathObject"). The statement itself is unchanged:batch()still requires the path to resolve to aLiveMaporLiveCounter, since ably-js deliberately kept the 92007 guard for non-LiveObject paths.Verified unaffected
All
value(),size(), subscribe-restriction, andbatch()behavioural statements across the LiveObjects docs were reviewed against the spec change and remain correct. Every<If lang="java">block mentioningInstancewas cross-checked to confirm its JavaScript counterpart is now consistent.