mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-11 06:42:21 +00:00
docs: add notes about apply diff
This commit is contained in:
parent
2b6dae8393
commit
868ee2e8cc
2 changed files with 8 additions and 0 deletions
|
@ -960,6 +960,8 @@ impl ContainerState for MovableListState {
|
|||
self.list().is_empty() && self.elements().is_empty()
|
||||
}
|
||||
|
||||
// How we apply the diff is coupled with the [DiffMode] we used to calculate the diff.
|
||||
// So be careful when you modify this function.
|
||||
#[instrument(skip_all)]
|
||||
fn apply_diff_and_convert(
|
||||
&mut self,
|
||||
|
@ -1237,6 +1239,8 @@ impl ContainerState for MovableListState {
|
|||
Diff::List(event)
|
||||
}
|
||||
|
||||
// How we apply the diff is coupled with the [DiffMode] we used to calculate the diff.
|
||||
// So be careful when you modify this function.
|
||||
fn apply_diff(&mut self, diff: InternalDiff, ctx: DiffApplyContext) {
|
||||
let _ = self.apply_diff_and_convert(diff, ctx);
|
||||
}
|
||||
|
|
|
@ -852,6 +852,8 @@ impl ContainerState for TreeState {
|
|||
self.nodes().is_empty()
|
||||
}
|
||||
|
||||
// How we apply the diff is coupled with the [DiffMode] we used to calculate the diff.
|
||||
// So be careful when you modify this function.
|
||||
fn apply_diff_and_convert(
|
||||
&mut self,
|
||||
diff: crate::event::InternalDiff,
|
||||
|
@ -972,6 +974,8 @@ impl ContainerState for TreeState {
|
|||
Diff::Tree(TreeDiff { diff: ans })
|
||||
}
|
||||
|
||||
// How we apply the diff is coupled with the [DiffMode] we used to calculate the diff.
|
||||
// So be careful when you modify this function.
|
||||
fn apply_diff(&mut self, diff: InternalDiff, ctx: DiffApplyContext) {
|
||||
if let InternalDiff::Tree(tree) = &diff {
|
||||
let need_check = !matches!(ctx.mode, DiffMode::Checkout | DiffMode::Linear);
|
||||
|
|
Loading…
Reference in a new issue