W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2013

Re: Better event listeners

From: Jake Verbaten <raynos2@gmail.com>
Date: Mon, 7 Jan 2013 09:18:24 -0800
Message-ID: <CAMCMjp2cXLD==F7NpV+_zzJDQ9xdqzcW+rcWySmmV5TeCbhiPw@mail.gmail.com>
To: Anne van Kesteren <annevk@annevk.nl>
Cc: "www-dom@w3.org" <www-dom@w3.org>, Yehuda Katz <wycats@gmail.com>
As a web developer if I were to design an on function with some kind of
delegation support I would have an API like: https://gist.github.com/4463430

The exact API doesn't matter.

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.

The other emphasis is that delegation filtering supports arbitrary
functions which allows people to delegate  whatever they want instead of a
limited string based DSL

I also currently use [ever][1] partially for cross-browser normalization
but mostly because I prefer writing `.on(...)` and it matches with the
other EventEmitter apis I use in the rest of my code. So there's definitely
value to having an API name that matches other conventions (and is terser).

  [1]: https://github.com/substack/ever#example
Received on Monday, 7 January 2013 17:18:56 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:20 UTC