Re: Better event listeners

On Tue, Jan 8, 2013 at 5:23 AM, Anne van Kesteren <annevk@annevk.nl> wrote:

> On Mon, Jan 7, 2013 at 6:18 PM, Jake Verbaten <raynos2@gmail.com> wrote:
> > Emphasis being on that `.on(...)` returns some kind of token that can be
> > used to remove the listener so we don't have to keep a reference to the
> > listener ourself somewhere.
>
> I think that makes a lot of sense. I like the idea of just returning a
> function reference.
>

Returning an object with a method is a more common pattern on the
platform.  It also allows adding related features in the future without
contortions (eg. Prototype's also has start(), to re-add the listener).

-- 
Glenn Maynard

Received on Tuesday, 8 January 2013 23:32:34 UTC