jundo
Undo library for browser and Node.
Install
npm install jundo
Usage
var jundo = new JUndo();
...
To mark an action which can be undone:
jundo.register(undoFunc, redoFunc);
undoFunc
is the function that will be invoked upon undoing, redoFunc
upon redoing. For example, if an action that adds an object to the screen has been performed, the undo function should remove that object while the redo function should add that object back to the screen.
To undo and redo:
if (jundo.undoCount() > 0) jundo.undo();
if (jundo.redoCount() > 0) jundo.redo();
To clear all registered functions:
jundo.clear();
Events:
jundo.on('change', func(evt, actionName, undoCount, redoCount) {
});
For more information, check out the specs.