v2.0.0 - A rethink
Up to this point, the history adapter has always tracked changes with JSON Patches, a data format that looks something like the below:
{
undo: [
{
op: "replace",
path: ["present", "value"],
value: 0,
},
],
redo: [
{
op: "replace",
path: ["present", "value"],
value: 1,
},
],
}
However, if your changes are more complex than your state shape, these can end up being pretty large.
Packages like redux undo instead store the entire version of state, and flip back and forth as needed.
In 2.0, createHistoryAdapter
will now use this approach, and a createPatchHistoryAdapter
version is available to use the previous behaviour.
Breaking changes
createHistoryAdapter
now uses entire copies of state, rather than patches of changescreatePatchHistoryAdapter
available for previous behaviour- similarly,
HistoryState
type no longer uses patches, whereasPatchHistoryState
does
- Second argument for
undoable
can no longer beisUndoable
function - needs to be config object
Other changes
- Build is no longer minified, allowing for better minification in the user's bundler