0

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...

2
  • 1
    You need to use waterfall instead. Commented Aug 28, 2014 at 10:12
  • Thanks for the help....I will read more Commented Aug 28, 2014 at 10:35

1 Answer 1

1
// 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);  
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.