-
Notifications
You must be signed in to change notification settings - Fork 2.4k
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add another async.parallel example #114
Comments
Hm... usage here is the same as in other functions basically. Ok, that's real-world example, hope it helps: var mongo;
var httpserv;
async.parallel([
function(callback) {
var mongodb = require('mongodb');
mongo = new mongodb.Db('project', new mongodb.Server("127.0.0.1", 27017, {auto_reconnect: true}));
mongo.open(callback);
},
function(callback) {
httpserv = require('http').createServer(function (request, response) {
process_request(request, response);
});
httpserv.listen(1337, callback);
},
], function() {
Application.init(mongo, httpserv);
}); PS: variables should be return values of course... but you've asked about real life - how it is, not how it should be :D |
Mariusa, I re-wrote your code example here: https://gist.github.com/4535307 |
I'd like the examples to be concise and clearly show the concept. I don't want them to teach JavaScript or Node.js. If people feel the underlying concept isn't described by the example then we should update it, otherwise I'll close this. |
Judging by the initial (incorrect) example proposal by @rlidwka the misunderstanding was more an issue of higher-order functions than the usage of async.parallel. I think the example in the docs is clear. |
Agreed, closing. |
Hi,
Would it be possible please to add an example to the docs showing how to use async.parallel with a real-life use?
I simply don't get it how it should work from docs, from test/ or from
http://stackoverflow.com/questions/7236899/nodejs-async-same-arguments-to-an-array-of-functions
A nice example would be to read 2 files and make a db call (all these 3 in parallel, async), and then do something with all 3.
Here's a start, which I can't tell how to make it work:
https://gist.github.com/2030967
Thanks
The text was updated successfully, but these errors were encountered: