>> Thinking of events as methods helps greatly with understanding them.
> I really think events as something different than methods, no a particular
> sort of methods. "fire as [[Call]]" is a convenience rather than considering
> the event as a method.
But what does “firing an event” really mean? If it *was* a method, then a
button would have it:
Button.prototype.clicked()
If the user clicks the button, the browser invokes the clicked() method. Thus,
the method invocation would *be* the event. And if you want to be informed of
it, you would intercept the method invocation.
Erik Arvidsson’s syntactic sugar points in a similar direction:
var obj = {
onfoo: event(a, b, c) { ... }
};
// addListener
obj.onfoo.add(function(a, b, c) {
assertEquals(this, obj);
...
});
With event(a,b,c) being an “interceptable method”. This is merely a different
way of thinking about your proposal (it doesn’t influence an implementation),
but I find that Erik’s proposal complements it perfectly.
--
Dr. Axel Rauschmayer
[email protected]
twitter.com/rauschma
home: rauschma.de
blog: 2ality.com
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss