I understand the philosophy of using callbacks as "Please call me back, when the job is done". Meaning, call me back after calculating all prime numbers. (avoid roundtrips)
I understand the event emitter philosophy as "Please interrupt me all the time you have news for me". Meaning, interrupt me for every single prime number. (lots of roundtrips, because I want to show the most current state all the time) So, a PrimeNumberGenerator could offer both versions for every purpose. And every single app might have a different understanding of the job size (or chunk size) and what are the news. So, the question for the app (which uses the PNG) would be, whether it wants to act on every event or just act on a final result. Lothar On Apr 28, 6:20 am, Mark Hahn <m...@hahnca.com> wrote: > How can it be sugar? It isn't compiled into anything else. Sugar is part > of a syntax in a language. > > You can call it whatever you want but it is a anonymous function being used > as a callback and passed to a node function that is called many times. > > On Fri, Apr 27, 2012 at 8:57 PM, crypticswarm <crypticsw...@gmail.com>wrote: > > > > > > > > > > > On Fri, Apr 27, 2012 at 10:40 PM, Mark Hahn <m...@hahnca.com> wrote: > > >> > I would say that in node calling a callback more than once is not only > >> discouraged, but forbidden, as if it were part of an implied, non written > >> contract. > > >> Then how do you explain ... > > >> http.createServer(function (req, res) { > > > http.createServer(function (req, res) {}) > > > is sugar for: > > > http.createServer().on('request', function (req, res) {}) > > > -- > > 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 nodejs@googlegroups.com > > To unsubscribe from this group, send email to > > nodejs+unsubscr...@googlegroups.com > > 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 nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en