Jeremy Martin (2013-07-11T00:12:41.000Z)
domenic at domenicdenicola.com (2013-07-16T14:32:39.062Z)
Once again, this problem goes beyond simply polluting the prototype (which is enough of an issue by itself). The semantics for Emitters are somewhat of an 80/20 thing: 80% of all emitters need some common behavior, but the remaining 20% is custom. Going back to Node.js, for instance: everything would be great with `emitter.on(...)`, `emitter.once(...)`, `emitter.off(...)`, `emitter.emit(...)`, etc. But now we need `emitter.listeners(event)`, `emitter.setMaxListeners(n)`, etc. So, we still end up with a custom EventEmitter that implements the additional node-specific stuff, but we have a new problem: how do we implement `emitter.listeners(event)`? Without an exposed `emitter._listeners` (or similar) mapping, we're hosed. So do we monkey-patch the listener (de)registration methods? Yada yada, you get the point. The same problem exists with DOM events and most likely in any other non-trivial Emitter scenario. As I see it, it simply isn't practical at this level. The pollution issue goes far beyond 4 or 5 or even 10 new properties/methods if it's going to be robust enough to handle the already-common use cases, and if anything is missed developers will still be forced to sub-class it anyway (which is the only hassle that might've been worth avoiding in the first place). Alternatively, as Rick said, we could simply have: ```js class Foo extends Emitter {} // or class Foo extends EventEmitter {} // or class Foo extends EddyEmitter {} // etc. ``` This, IMO, is *far* more favorable and *far* less obtrusive (and already in the works).