angular-restmod
angular-restmod copied to clipboard
Model undo/redo mixin
I'd like to propose a new mixin that would support the ability to track revisions for undo/redo support.
API example:
model.$save(); // example: { name: "Sally" }
model.$save(); // example: { name: "Sallie" }
model.$save(); // example: { name: "Molly" }
model.$revert(2); // reverts to: { name: "Sallie" }
Any thoughts?
We could store encoded data into this 'revisions' using after-save
or after-encode
hooks.. Then reverting would just be a matter of calling $decode
with the revision encoded data.
I'm thinking about using something like https://github.com/flitbit/diff to store the diffs in localstorage and then just unwind when reverted.