If you need to keep the emitter around for a while, and want to bind a
handler for a single use, then this pattern works well:
emitter.on("event", function runonce (er, data) {
emitter.removeListener("event", runonce)
// dosomething
})
Being inside a closure doesn't really affect the story much. Since
node runs on v8, and not an outdated ancient version of jscript, you
don't have to worry about circular references any more ;)
Mark-and-sweep does a fine job of reclaiming unreachable objects.
--i
--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.