On Sep 15, 2014, at 10:09 AM, // ravi <[email protected]> wrote: > On Sep 15, 2014, at 1:01 PM, Alex Kocharin <[email protected]> wrote: >> >> Promises just wrap callbacks. So you had callback hell, now you have wrapped >> callback hell. Nice change, huh. > > > Actually yes, I think it is. Readable code is worth it, in my view.
What you really get with promises: Abstraction over exact order. You're no longer describing what to do next after a task, but instead, describing what depends on what inputs. For simple problems, the result is the same and promises are just expensive, complicated callbacks. For a complex, one, however, it lets you write functions that stay named in the problem domain rather than solution domain more easily. Promise.all returns a promise that gives all the values of the promises you pass in. And remember a value without .then can be substituted for a promise -- so you now have an interface that can interpret "later values" and "already available" values identically. That's where the real power comes in: Promises that join and collect results of promises, functions that accept promises (or plain values) and give a promise result. Aria -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: 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 unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/0A061A1E-0B06-48AF-B5A5-F4801FE286C9%40nbtsc.org. For more options, visit https://groups.google.com/d/optout.
