-
Notifications
You must be signed in to change notification settings - Fork 452
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
💥 Rename Doc
op events
#486
Open
alecgibson
wants to merge
1
commit into
v2
Choose a base branch
from
rename-op-events
base: v2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The `Doc` op events are currently a little confusing: a `json0` "op" can be shattered into multiple "component ops". In the current naming, the "op" emits a `'op batch'` event, and the "op component" emits an `'op'` event. However, calling the op an "op batch" is a little bit misleading, because the "batch" is always an op representing a single version number increase, and potentially considered a single conceptual change. For example, a remote client might submit a single op: ```js [ {p: ['a'], oi: 'foo'}, {p: ['b'], oi: 'bar'}, ] ``` Under the **current** naming scheme, this emits the following events: 1 `'before op batch'`: `[{p: ['a'], oi: 'foo'}, {p: ['b'], oi: 'bar'}]` 2 `'before op'`: `[{p: ['a'], oi: 'foo'}]` 3 `'op'`: `[{p: ['a'], oi: 'foo'}]` 4 `'before op'`: `[{p: ['b'], oi: 'bar'}]` 5 `'op'`: `[{p: ['b'], oi: 'bar'}]` 6 `'op batch'`: `[{p: ['a'], oi: 'foo'}, {p: ['b'], oi: 'bar'}]` This can be considered a little surprising, and you may expect the `'op'` event to be emitted after the whole op (not its shattered components) have been applied. Under the **new** naming scheme, the following events are emitted: 1 `'beforeOp'`: `[{p: ['a'], oi: 'foo'}, {p: ['b'], oi: 'bar'}]` 2 `'beforeOpComponent'`: `[{p: ['a'], oi: 'foo'}]` 3 `'opComponent'`: `[{p: ['a'], oi: 'foo'}]` 4 `'beforeOpComponent'`: `[{p: ['b'], oi: 'bar'}]` 5 `'opComponent'`: `[{p: ['b'], oi: 'bar'}]` 6 `'op'`: `[{p: ['a'], oi: 'foo'}, {p: ['b'], oi: 'bar'}]` This way, you get the `'op'` event after the whole op has been applied. It also makes it more explicit that you're actively listening out for the shattered op components where applicable. Note that we also move the events to camelCase to be consistent with the Backend middleware actions.
alecgibson
force-pushed
the
rename-op-events
branch
from
June 22, 2021 16:05
945d69e
to
df3679a
Compare
As discussed with @ericyhwang :
|
Another idea from today:
|
(Was seeing if we could delete the v2 branch, which this PR points to, but that causes the diff to get wonky. Best leave it alone for now, probably.) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes:
The
Doc
op events are currently a little confusing: ajson0
"op" canbe shattered into multiple "component ops".
In the current naming, the "op" emits a
'op batch'
event, and the"op component" emits an
'op'
event.However, calling the op an "op batch" is a little bit misleading,
because the "batch" is always an op representing a single version number
increase, and potentially considered a single conceptual change.
For example, a remote client might submit a single op:
Under the current naming scheme, this emits the following events:
'before op batch'
:[{p: ['a'], oi: 'foo'}, {p: ['b'], oi: 'bar'}]
'before op'
:[{p: ['a'], oi: 'foo'}]
'op'
:[{p: ['a'], oi: 'foo'}]
'before op'
:[{p: ['b'], oi: 'bar'}]
'op'
:[{p: ['b'], oi: 'bar'}]
'op batch'
:[{p: ['a'], oi: 'foo'}, {p: ['b'], oi: 'bar'}]
This can be considered a little surprising, and you may expect the
'op'
event to be emitted after the whole op (not its shatteredcomponents) have been applied.
Under the new naming scheme, the following events are emitted:
'beforeOp'
:[{p: ['a'], oi: 'foo'}, {p: ['b'], oi: 'bar'}]
'beforeOpComponent'
:[{p: ['a'], oi: 'foo'}]
'opComponent'
:[{p: ['a'], oi: 'foo'}]
'beforeOpComponent'
:[{p: ['b'], oi: 'bar'}]
'opComponent'
:[{p: ['b'], oi: 'bar'}]
'op'
:[{p: ['a'], oi: 'foo'}, {p: ['b'], oi: 'bar'}]
This way, you get the
'op'
event after the whole op has been applied.It also makes it more explicit that you're actively listening out for
the shattered op components where applicable.
Note that we also move the events to camelCase to be consistent with
the Backend middleware actions.