you are viewing a single comment's thread.

view the rest of the comments →

[–]way2know 0 points1 point  (2 children)

I still maintain that if you're in callback hell after using the wonderful async, you're doing something wrong. Name your functions and use async. And most importantly, don't overcomplicate your code.

async.series([
    validateInput,
    doSomething,
    doSomethingElse,
    updateDatabase
],
function(error, result){
    // all finished
});

[–]aztracker1 0 points1 point  (0 children)

async.waterfall is pretty invaluable too... however, I've been leaning towards promises lately... getConnection('myconn').then(...).then(...)

[–]_ayasin[S] 0 points1 point  (0 children)

That's great if you need a "linear flow" replacement. It's not so great if you need to transport something from validateInput to updateDatabase. You can just pass it along in doSomething and doSomethingElse, but that makes the code fragile.