dva-immer-undo-redo
A plugin of dva to support undo redo based on Immer.
Install
$ npm install dva-immer-undo-redo --save
Usage
; const app = ;app;
options
options.namespace
: property key on global state, type String, Defaulttimeline
options.include
: namespaces that you want to include in the timeline. Default[]
options.limit
: the max times to undo or redo, Default1024
Undo
;
Redo
;
Clear all undo redo status
;
Replace timeline
// state of count's model count: 0// add reducer { statecount += 1;}; // { count: 1 }; // { count: 2 }; // { count: 3 }; // { count: 1 }; // { count: 3 }
Clear timeline
// state of count's model count: 0// add reducer { statecount += 1;}; // { count: 1 }; // { count: 2 }; // { canRedo: false, canUndo: false }
State Structure
timeline: {
canRedo: false,
canUndo: false,
undoCount: 0,
redoCount: 0,
}