mutativejs/use-travel

Proposal: archive() automatically merges all patches when autoArchive is disabled

Closed this issue · 0 comments

When autoArchive is disabled, archive() may store a large number of temporary patches in controls.patches, which could lead to unnecessary waste of memory data size. Therefore, we can utilize the Mutative apply() to merge them into as small a patch data as possible, without altering the final outcome.

For example,

Two inversePatches:

[
  [{"op":"replace","path":[],"value":3}],
  [{"op":"replace","path":[],"value":4}]
]

They will be merged into:

[
  [{"op":"replace","path":[],"value":3}]
]