Re: [WebIDL] Simplify callbacks

On Thu, 15 Dec 2011, Cameron McCormack wrote:
> 
> * you can store data on the object and have multiple callbacks using 
> that same object, so that they can all share the same state easily 
> (i.e., there are multiple callback methods on the object)
> 
> If we use "handleEvent" everywhere, then that reduces the usefulness of 
> object-with-property, since you won't be able to use the same 
> handleEvent property as the callback function for different callback 
> types.

I think it's considerably more likely that one would desire to use 
an object of this nature with multiple callbacks of the same type (e.g. 
various different events, or the same callback on various different 
instances of a particular interface) than it is that the same object will 
be used with different callbacks. So if we want to address that use case, 
changing the name is insufficient, while simultaneously having the 
disadvantages I listed in my last e-mail.


> > Don't think of "handleEvent" as meaning "handle a DOM Event object". 
> > Think of it as "handle an event", the event being "the callback was 
> > invoked".
> 
> Yes, we can re-think what the name means like this.

I don't see it as a rethinking of the name. Personally I never even 
realised there could be an interpretation of handleEvent() that referred 
specifically to DOM Event objects until people started saying we should 
call the method with other names. I've used the name HandleEvent in APIs 
for years.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Thursday, 15 December 2011 03:22:15 UTC