Is it possible to implement an undo/redo engine with JavascriptMVC?
Probably. While I've never worked with JavascriptMVC, here is the principle how undo works:
Instead of directly changing anything, you put the code to change something in a "command" object. The command object has two methods:
undo()
andredo()
.When an operation is executed, you create the necessary command objects, invoke
redo()
on them and add them to a list (the "undo stack").For undo, pop items off the list and invoke
undo()
on them and push them on the "redo stack".For redo, pop from the "redo stack", invoke
redo()
and push the item on the undo stack.
It doesn't matter whether you do this on the server or on the client but I suggest that you chose one side and stick with it.
What are you going to use it for? Instead of using undo/redo, can you use it's history plugin? That way undo/redo will work with the forward and back buttons.