added support for accessing results of other tasks in async.auto #12

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
5 participants

thejh commented Feb 19, 2011

As wanted in issue #7. Usage example:

async.auto({
    get_data: function(callback){
        // async code to get some data
        setTimeout(function() {
            callback(null, 'this is some data');
        }, 500);
    },
    make_folder: function(callback){
        // async code to create a directory to store a file in
        // this is run at the same time as getting the data
        setTimeout(function() {
            callback(null, 'blahfu123');
        }, 700);
    },
    write_file: ['get_data', 'make_folder', function(callback){
        setTimeout(function() {
            callback(null);
        }, 700);
    }],
    email_link: ['write_file', function(callback, results){
        console.log('put "'+results.get_data+'" into "'+results.make_folder+'"');
        setTimeout(function() {
            callback(null);
        }, 700);
    }]
});
@ghost

ghost commented Mar 15, 2011

Exactly what i needed. Thanks for this addition.

+1 for this feature

I recommend adding the results object to the final callback. At least I have an equal need for that. That needs only three lines highlighted in this commit:

https://github.com/eirikurn/async/commit/bb047d1fb05d79607c07e5a5a6a70dba49ba83f5

thejh commented Mar 23, 2011

Thanks, eirikurn, looks like a good idea.

Contributor

brianmaissy commented Feb 20, 2013

This seems to have been implemented since the pull request was opened, so it should be closed.

@caolan caolan closed this Mar 2, 2013

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