Skip to content

Instantly share code, notes, and snippets.

@emadb
Last active December 17, 2015 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emadb/5525652 to your computer and use it in GitHub Desktop.
Save emadb/5525652 to your computer and use it in GitHub Desktop.
Come cacchio funziona!! Perchè complete non viene mai eseguito??
var async = require('async');
var functions = [];
functions.push(function(){ console.log("1"); return test1(1); });
functions.push(function(){ console.log("2"); return test1(2); });
functions.push(function(){ console.log("3"); return test1(3); });
async.parallel(functions, function(err, result){
console.log('complete', result);
});
function test1 (value){
return "hello " + value;
}
@fakemau5
Copy link

fakemau5 commented May 6, 2013

my 2c: passa la callback che va invocata dalle tue funzioni parallele:

var async = require('async');
var functions = [];

functions.push(function(callback){ setTimeout( function(){console.log("1"); callback(null,test1(1));}, 500 )});
functions.push(function(callback){ console.log("2"); callback(null,test1(2)); });
functions.push(function(callback){ console.log("3"); callback(null,test1(3)); });

async.parallel(functions, function(err, result){
    console.log('complete', result);
});

function test1 (value){
    return "hello " + value;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment