[whatwg] Fixing undo on the Web - UndoManager and Transaction

On Mon, Sep 12, 2011 at 5:19 PM, Jonas Sicking <jonas at sicking.cc> wrote:

> Could you please supply an example where the apply/reapply split leads
> to cleaner or otherwise better code than using a boolean argument?
>

apply: function() {
  // modify dom
  // send data back to server
},
unapply: function() {
  // ask server what I should do for undo
  // modify dom
},
reapply: function() {
  // ask sever what I should do for redo
  // modify dom
}

I can't give you a code from existing apps because such apps do not use
undoManager API.

Having slightly different signatures for the apply function on both
> transaction feels like a much smaller problem. Either we can rename
> 'apply' on automatic transactions, or we can give it a boolean
> argument too which is passed 'false'. It's easy enough to ignore
> arguments in JS, simply don't put them in your function signature.
>

I'm fine with adding a boolean argument if we're splitting the interface for
automatic and manual transactions because then we don't need to have boolean
argument in automatic transaction's apply.

- Ryosuke

Received on Monday, 12 September 2011 18:06:52 UTC