angular-restmod icon indicating copy to clipboard operation
angular-restmod copied to clipboard

Model undo/redo mixin

Open amcdnl opened this issue 10 years ago • 2 comments

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?

amcdnl avatar Sep 06 '14 18:09 amcdnl

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.

iobaixas avatar Sep 16 '14 01:09 iobaixas

I'm thinking about using something like https://github.com/flitbit/diff to store the diffs in localstorage and then just unwind when reverted.

amcdnl avatar Sep 16 '14 14:09 amcdnl