Re: Better event listeners

On Jan 10, 2013, at 7:39, "Anne van Kesteren" <annevk@annevk.nl> wrote:

> On Wed, Jan 9, 2013 at 3:27 AM, Domenic Denicola
> <domenic@domenicdenicola.com> wrote:
>> What about just... "off"?
> 
> Well that is the pattern some of the registration mechanism use,
> including addEventListener() today. However, it requires keeping track
> of all arguments passed. Or at least those that determine the "key"
> for what an event listener is (currently that would be type, callback,
> capture flag).
> 
> It's already not that convenient to keep track of the callback, so
> maybe instead we should use a mechanism similar to setInternal() and
> friends. They return an integer you can later pass to a remove method.
> 
> That doesn't seem quite as elegant as returning a function pointer
> however as per Jake's proposal. (Returning an object here with a
> method seems overkill to me.)
> 
> 
> -- 
> http://annevankesteren.nl/
> 


I meant that, if an object with methods were returned, the method should be named "off" as opposed to "cancel" or "stop" etc. Agreed that a function instead of an object is more elegant, however.

Received on Thursday, 10 January 2013 13:08:00 UTC