问题描述:

npm install async

Example :

 var async = require('async');

var a = function(callback)

{

console.log("Hello ");

callback(null,'vals1')

return 'prop'

};

var b = function(callback)

{

//I want get return 'prop' from a() its posible ?

console.log("World");

callback(null,"vals2")

};

async.series(

[

a,b

],function(err,vals){

console.log(vals) //[val1,vals2]

console.log('finals')

}

);

I want get return 'prop' from a() to b(). Its posible ?

Thank you...

网友答案:
// Pretend this is some complicated async factory
async.waterfall([
    function(callback){
        console.log('1');
        callback(null, 'one', 'two');
    },
    function(arg1, arg2, callback){
        console.log('2::::::' + arg1 + arg2 +':::')
      // arg1 now equals 'one' and arg2 now equals 'two'
        callback(null, 'three');
    },
    function(arg1, callback){
        // arg1 now equals 'three'

        console.log('3::::::' + arg1 )
        callback(null, 'done');
    }
], function (err, result) {
   console.log(result);  
});
相关阅读:
Top