Coderwall post

Ever wanted to support undo/redo in your JS app?

I did, so I wrote a CommandManager that supports execution, unexecution and reexecution of commands.

Try the demo: http://alexanderbrevig.github.com/CommandManager.js/examples/

CommandManager.execute({
  execute: function(){
    // do something
  },
  unexecute: function(){
    // undo something
  }
});

//call unexecute of prev. command
CommandManager.undo(); 
//call execute of prev. command
CommandManager.redo(); 
blog comments powered by Disqus

Published

22 October 2012

Category

Tags