FAQ
I'd recommend as Tim suggested, or with little modification to your
code, something like this.

var results
if (cond) {
async1(function (err, res) {
results = res
next()
})
}
else {
async2(function (err, res) {
results = res
next() // <= or pass in the results?
})
}

function next () {
// here need to do something with results.

}


Thomas Blobaum
https://github.com/tblobaum

On Tue, Aug 7, 2012 at 11:35 AM, 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+unsubscribe@googlegroups.com
For more options, visit this group at
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 10 of 19 | next ›
Discussion Overview
groupnodejs @
categoriesnodejs
postedAug 7, '12 at 4:44p
activeAug 9, '12 at 7:14a
posts19
users10
websitenodejs.org
irc#node.js

People

Translate

site design / logo © 2022 Grokbase