Pattern 1: if (cond) results = async1(_); else results = async2(_);
Pattern 2: results = cond ? async1(_) : async2(_); See https://github.com/Sage/streamlinejs for details. On Tuesday, August 7, 2012 6:35:20 PM UTC+2, Dan Milon wrote: > > I am wondering which are the different patterns to handle cases like > > > var results > if (cond) { > async1(function (err, res) { > results = res > }) > } > else { > async2(function (err, res) { > results = res > }) > } > // here need to do something with results. > > The problem is obvious, but i cannot see any good way to overcome it. > -- 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