Proposal to add EventEmitter to core [ES7]
andrea.giammarchi at gmail.com
Mon Jun 1 08:58:20 UTC 2015
not only node implemented EventEmitter without even reading what DOM had to
offer before, I see whatever EventEmitter proposal would land in ES7
something related to lightweight traits, and not a class to extend.
Extending EventEmitter without having the ability to extend something else
looks like a poor choce to me, having a list of well known traits including
the EventEmitter one would be better.
About current node implementation:
1. it doesn't accept objects as listeners, a not so common but actully
widely used practice on the WEB
2. it does accept multiple times the same listener, a footgun on DOM-land
3. it has a maximum amount of listeners per objects, a footgun on
4. it has an `on` method but not an `off`, not convenient on DOM where
an app doesn't have same listeners forever due Ajax/client<->server
interaction nature, I'd like a more consistent naming convention
5. it exposes the ability to remove/retrieve listeners you don't own,
again a footgun on DOM or anywhere the code is own by multiple libraries
Just my 2 cents.
On Sun, May 31, 2015 at 6:46 PM, aakarsh1997 <aakarsh1997 at gmail.com> wrote:
> I propose the inclusion of the node/io EventEmitter class in core
> targeting ES7.
> The .on/.emit model is very popular in the ECMAScript land, and it
> suits the language a lot. We use events pretty much everywhere in the JS
> It makes sense for the standard EventEmitter class used commonly to be
> included in core. With ES6 classes, userland code classes extending the
> EventEmitter class would be pretty common and useful even in environments
> like browsers.
> I think the `.once` method from the node/io EventEmitter class _could_ be
> left out from standard implementation mainly because we would rather use
> Promises there. Although it would also make sense to keep it in for further
>  https://iojs.org/api/events.html
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss