-
Notifications
You must be signed in to change notification settings - Fork 535
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
Refactor forest's applyDelta to return a visitor #17163
Conversation
⯅ @fluid-example/bundle-size-tests: +2.26 KB
Baseline commit: 0bde699 |
Co-authored-by: Craig Macomber (Microsoft) <[email protected]>
"Must release existing visitor before acquiring another", | ||
); | ||
this.events.emit("beforeChange"); | ||
|
||
this.invalidateDependents(); | ||
assert( |
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.
previously this used to be enough to assert that no cursors (other than the one used foe the update) exist during delta application. With this change, this check (and likely a similar one in chunked forest) is no longer enough.
There are two approaches we can take to close this safety gap:
- Add
assert(this.forest.activeVisitor === undefined)
into Cursor.setToAboveDetachedSequences (this will ban any use of cursors while you have a visitor) - OR: in the visitor implementation, before it makes each change, do
this.invalidateDependents(); this.currentCursors.size === 1
, and remove those checks from here (this will allow using cursors inbetween edits, for example inspecting the editiable tree on the delta events.)
Equivalent changes will be needed for chunked forest.
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.
If you go with the second option, you might want to move before and after change into each individual edit as well, or at least update the docs on those events to clarify when they fire.
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.
Nice catch! Thanks for noticing that. I'm guessing we want option #2 given where we're headed.
Description
Changes applyDelta to acquireVisitor so that multiple visitors can be used together.