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

Jonas Sicking jonas at sicking.cc
Mon Sep 12 17:19:19 PDT 2011


On Sat, Sep 10, 2011 at 7:01 PM, Ryosuke Niwa <rniwa at webkit.org> wrote:
> On Tue, Aug 30, 2011 at 7:22 PM, Jonas Sicking <jonas at sicking.cc> wrote:
>>
>> I'm really failing to think of a case when you'd really want to have
>> apply and reapply as separate callbacks. Even in the most trivial
>> cases it seems like it would lead to code duplication which is
>> something that even the most basic developers try to avoid. And
>> especially in more complex scenarios like collaborative editors it
>> seems like you really wouldn't want to duplicate the logic between
>> apply and reapply.
>>
>> So once we have the boolean argument to apply, I fail to see any cases
>> where the reapply approach is better. I'd love to see some examples if
>> you have any?
>
> One more reason not to add the boolean argument is that apply function is
> supplied in both automatic and manual transactions yet reapply call never
> happens in automatic transactions. This makes odd for apply function to take
> the boolean argument in automatic case.

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

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.

/ Jonas



More information about the whatwg mailing list