EventEmitter is optimised under the hood, so that if you only ever add one listener, that is what is pretty much what is happening.
adding a listener: https://github.com/joyent/node/blob/master/lib/events.js#L139-141 calling the only event-listener https://github.com/joyent/node/blob/master/lib/events.js#L74-99 there any many times you need extra event listeners. when debugging, for example, or maybe you want to register another end listener, because you want to be notified when the stream has completed, so that you can do something else. On Sat, Jul 28, 2012 at 12:38 AM, Joran Greef <jo...@ronomon.com> wrote: > Looks good. > > How often in practice are multiple on("end") and on("readable") events going > to be attached? > > Would prefer to just have plain vanilla stream.onEnd = function() {} and > stream.onReadable = function() {} callbacks. > > > On Friday, July 27, 2012 6:57:01 AM UTC+2, Isaac Schlueter wrote: >> >> I think the real problem is with readable streams. Writable streams >> are pretty easy to implement, but the readable side is unnecessarily >> difficult and too easy to get wrong. >> >> Here's a proposal in code: https://github.com/isaacs/readable-stream >> >> The readme explains the position, and the implementation makes it easy >> to play around with. A base class and a fs readable stream class are >> provided. Note that Readable.pipe() is very short and simple :) >> >> >> On Sun, Jul 15, 2012 at 7:25 PM, Dominic Tarr <dominic.t...@gmail.com> >> wrote: >> > I've been writing and using a lot of streams lately, >> > and have some proposals for some small changes to node's streams. >> > >> > https://gist.github.com/3117184 >> > >> > in some parts it's a tightening up on expected behaviour, >> > in others it's a few small changes to Stream#pipe. >> > >> > cheers, Dominic