yorkie
yorkie copied to clipboard
Change the interface from `document.update()` to `document.change()`
Description:
Currently, we use document.update()
and document.subscribe()
as shown below:
const doc = new yorkie.Document('example');
doc.update((root) => {
// modify the document contents...
});
document.subscribe((event) => {
// If the event type is `local-change` or `remote-change`
for (const changeInfo of event.value) {
// changeInfo represents the modifications made during a document update
const {message, operationInfos} = changeInfo;
for (const opInfo of operationInfos) {
// ex) { type: 'increase', value: 1, path: '$.counter' }
switch (opInfo.type) {
case 'increase':
// Do something...
break;
}
}
}
}
});
When the event type is local-change
or remote-change
, the event value type is an array of ChangeInfo
.
ChangeInfo
represents the modifications made during document.update
.
The different names, update
and change
, can be confusing when using the method.
Therefore, it would be better to either change ChangeInfo
to UpdateInfo
or to unify the method name to change
.
Since Yorkie already uses the terms operation
and change
internally,
it would be better to change the method name to change
.
Why:
Using the term ChangeInfo
to represent the modifications made during an doc.update
can cause confusion.
To maintain consistency, let's change the method name to change
I'd like to try this ... 😄
@kongnayeon Good luck!
Is it still good to change? 🤔 It would be good to close it for now and reopen this again later if necessary.