I wrote a blogpost about this specific topic: http://joseoncode.com/2012/06/24/messing-with-cps-in-js/
for me there are two ideal situations: - a language with an specific syntax for asynchronous flows like streamlinejs, icedcoffeescript, f# - or make a Continuation Passing Style version of the javascript constructs (if, for, while, try/catch) (similar to lisp family languages) there are also a lot of async libraries I know. 2012/8/7 Dan Milon <[email protected]> > 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<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 [email protected] > To unsubscribe from this group, send email to > nodejs+unsubscribe@**googlegroups.com<nodejs%[email protected]> > For more options, visit this group at > http://groups.google.com/**group/nodejs?hl=en?hl=en<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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
