On Wednesday, December 12, 2012 10:52:19 AM UTC-5, greelgorke wrote:

> Well, DOM Event API defines the EventListener interface. you could do this:
> document.body.addEventListener('click', 
> {foo:'foo',handleEvent:function(ev){console.log(this.foo)}})
> and this will print foo to your console, but thats, right. it's possible 
> just to pass a function and most of devs do this and use closure scope 
> instead or even bind.
>
 
Right, I always forget about that pattern.  Perhaps there is a reason for 
that (it sucks? :-)

But, I think there are few other "callback" patterns implemented in the 
popular libraries that do this anyway.

Also, forgot to mention in my previous post on this subject, attempts to 
"sugar" some of the patterns where you pass additional data (like, say, if 
you could macro-ize some of it) end up running into problems in the 
"removeEventHandler" APIs, where you need to pass whatever it was you 
passed to the REAL addEventHandler.  Bitten me more than once, anyway.

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to