Hi Issac, Thanks for the explanation.
It really makes a lot of sense when events are used in a more "interactive" way allowing an listener to modify the target. There was a case however for events when they are used just as a notification pump, to warn that something happened but without being able to actually interfere on the flow, that it might be async. Since I'm new to node-js, instead of assuming the first (which I agree is the most common usage), I decide to ask. :) Cheers, Eric. 2013/1/11 Isaac Schlueter <[email protected]> > If you think about how events are used, it's really important that > emit() is synchronous. > > If I do `foo.on('bar', myFunction)`, then I want myFunction to be > called *right when 'bar' happens*, not some time *after* 'bar' has > happened. > > This is especially important when you think about a http request. We > parse the headers, and then emit the 'request' or 'response' event and > call your handler right away, before anything else happens to it. If > we waited until later, it'd be in a weird buffering state, and who > knows what might have happened in the meantime. > > Of course, `emit()` might be called at any arbitrary time. So > `foo.on('bar', fn)` doesn't wait around blocking until `'bar'` is > emitted. The emission could come on nextTick, or hours later. But, > WHEN 'bar' is emitted, fn is called right away in that exact moment. > > > On Fri, Jan 11, 2013 at 9:31 AM, Eric Chaves <[email protected]> wrote: > > Thanks! > > > > 2013/1/11 Dan Milon <[email protected]> > >> > >> danmilon > > > > > > > > -- > > 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 > > -- > 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 > -- 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
