promises, generators, events aside (wonder, nobody mentioned async module) 
the so called callback-hell appears when your functions share some kind of 
state, in this case via the closure scope. the obvious way out of it is to 
reduce shared state, flatten as suggested already, and push the needed 
state far out of your code. you can use partial application on your 
callbacks, if they need operate on some implicit params (closure-scoped 
variables are just that: implicit parameters) or remain stateless by taking 
all params explicitly.

Am Montag, 15. September 2014 21:10:04 UTC+2 schrieb // ravi:
>
> On Sep 15, 2014, at 1:26 PM, Aria Stewart <[email protected] <javascript:>> 
> wrote:
>
> On Sep 15, 2014, at 10:09 AM, // ravi <[email protected] <javascript:>> 
> wrote:
>
> On Sep 15, 2014, at 1:01 PM, Alex Kocharin <[email protected] 
> <javascript:>> 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.
>
>
> <snip happens>
> 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.
>
>
> I am not unaware of these advantages, but the OP was speaking specifically 
> of callback hell with an example that indicated the issue is the familiar 
> one of readable (and manageable) code flow.
>
> —ravi
>
>
>

-- 
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/e35f3a0a-2392-415a-9a6f-5faabb335ab5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to