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

Ryosuke Niwa rniwa at webkit.org
Tue Aug 9 15:11:28 PDT 2011


On Tue, Aug 9, 2011 at 2:55 PM, Jonas Sicking <jonas at sicking.cc> wrote:
>
> I don't think it's a matter of which use cases can or can't be solved with
> either solution. It's pretty clear to me that all scenarios can be solved
> with either API.
>

Right, they're isomorphic.

It's just a matter of which pattern is more common and so which one we
> should make more convenient. If almost everyone puts the same code in apply
> and reapply then we're just creating more work for people.
>

>
Here's how you'd implement the apply/reapply/unapply syntax using simply
> apply/unapply
>
> apply: function() { if (!this.applied) { action1(); this.applied = true; }
> else { action2(); }
> unapply: unapply
>

One thing I don't like about this approach is that it requires a flag.  With
my proposal, all you need to do is to call a function.  Also, we can make it
so that when you don't supply a value to reapply (i.e. reapply is null),
then undoManager automatically calls apply instead (I always intended this
behavior from the beginning but I've apparently left this details out).

- Ryosuke



More information about the whatwg mailing list