-
Notifications
You must be signed in to change notification settings - Fork 98
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
Allow specifying a topic when subscribing to a document #487
Conversation
Codecov Report
@@ Coverage Diff @@
## main #487 +/- ##
==========================================
+ Coverage 89.71% 90.19% +0.47%
==========================================
Files 69 69
Lines 5690 5985 +295
Branches 551 568 +17
==========================================
+ Hits 5105 5398 +293
+ Misses 390 381 -9
- Partials 195 206 +11
... and 3 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
- To test the move operation, add `drag&drop` to the todo example
385b17e
to
3f7258d
Compare
42d8161
to
981b78e
Compare
981b78e
to
5b003ac
Compare
`waitFor` continuously registers the listener, which may result in missed event detections if an event occurs before the registration. Therefore, `waitFor` has been replaced with `waitStubCallCount` to verify the number of times the callback function is called and which events are executed.
…cribe` Modify the `selectPriv` method to return `TextChange` when setting the initial selectionMap
- `Modified` refers to the changes made when an operation is executed. - `UpdateInfo` represents the changes made when `doc.update()` is called and it is the value exposed to the user. - The `updates` field in `UpdateInfo` contains an array of `UpdateDelta`, which are the transformed values of `Modified`.
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.
Overall good. I left a few comments.
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.
LGTM.
) * Modify `doc.subscribe` function to allow specifying a topic * Add document.getValueByPath * Specify the doc.subscribe event value for each operation * Use `waitStubCallCount` instead of `createEmitterAndSpy` and `waitFor` `waitFor` continuously registers the listener, which may result in missed event detections if an event occurs before the registration. Therefore, `waitFor` has been replaced with `waitStubCallCount` to verify the number of times the callback function is called and which events are executed. * Add test that `remote-change` event is properly detected in `doc.subscribe` * Modify the `selectPriv` method to return `TextChange` when setting the initial selectionMap --------- Co-authored-by: Youngteac Hong <[email protected]>
What this PR does / why we need it?
1. Subscribe to Document with Specified Target
In the case where there are multiple data (such as
root.todos
,root.counter
, etc.)in one document root, as in the example above, if you want to perform a specific task
only when
root.todos
is changed,as-is
) you have to traverse thechangeInfo.paths
in the event valueand check if the path(
$.todos
) has been changed.to-be
) You can specify the target path as$.todos
and register a callback function to execute when the specified path is changed.
So, in the example, the
doc event
occurs every time the document is changed,but the events for todos, counter, and quill are only triggered
when their respective path or any of their nested values are changed.
2. Improvement of Event Value for Local/Remote Change
In document subscription, the event value provides an array of operations, which is difficult to use.
Provide useful information to the user from the operation.
as-is
){ parentCreatedAt: TimeTicket, executedAt: TimeTicket, value: Primitive }
to-be
){ type: 'increase', value: 1, path: '$.counter' }
Any background context you want to provide?
What are the relevant tickets?
Fixes #445
Checklist