Rick Waldron (2013-07-11T01:16:44.000Z)
domenic at domenicdenicola.com (2013-07-16T14:51:43.787Z)
On Wed, Jul 10, 2013 at 7:22 PM, Andrea Giammarchi <andrea.giammarchi at gmail.com> wrote: > tis works same way you can define toString during class definition ... so > what happens, nothing unexpected. This response completely dodges the point I've made and toString is a poor comparison. toString is only one method and it's expected that a class (or previously Constructor.prototype.toString) would define it's own toString with an appropriate return value. > I think you didn't understand what is boundTo ... completely a part from > events. No, I understood it just fine. I was just listing out every method listed here https://github.com/WebReflection/eddy#event-driven-js but you snipped the rest of the sentence, so now it's out of context. > Because in 10 years I haven't seen such standard Emitter so it's about > the time to agree on an event based mechanism, IMO, since we all talk about > events in every asynchronous world. What I'm saying is: let's agree to an Emitter and make it a standard library module. > it's also more semantic than `node.addEventListener('load')` since you say > and write and mean `node.on('load');` What are you talking about? Look again at the example I'm commenting on and explain to me how to register two different handlers for an event named "type1". Yes, addEventListener sucks. Yes, on("foo", handler) is great. > You are right, in that inline version this is correct. > I didn't propose that indeed and you can use more than a handler without > problems. Of course, I was referring to the syntactic form that Matthew proposed: ```js var obj = { on foo() {} } ``` (this is still part of my point above, re: registering multiple handlers for the same named event) > If there was a mechanism to have that simplified today I believe it would > have been used. It may not be "simple" by your definition (it isn't simple by mine), but it's the most common practice... ```js var Emitter = require("events").EventEmitter; function Foo() { Emitter.call(this); } Foo.prototype = Object.create(Emitter.prototype); Foo.prototype.constructor = Foo; ``` Which corresponds to: ```js class Foo extends Emitter { constructor() { super() } } ``` Maybe I'm missing something in your argument here? If so, I apologize. > So are you willing to talk about that standard EventEmitter and put it in > ASAP as native constructor every object could inherit from ? I absolutely stand by championing such a standard module. > 'cause this would be already a lot for me and everyone else out there, a > native way to have emitters in core (hopefully able to work with DOM nodes > too) Well, any object right?