adelphia
adelphia

Reputation: 187

Call functions in a js array of functions in parallel

I am trying to implement parallel(funcList, done) to implement the call to each of the functions passed at the same time.

    parallel([
    function(cb) { setTimeout(1000, cb); },
    function(cb) { setTimeout(2000, cb); },
    function(cb) { $.get('example.com').always(cb); }
],
function() { alert('done'); }

);

Any pointers would be a great help..

Upvotes: 1

Views: 1549

Answers (1)

datfinesoul
datfinesoul

Reputation: 11

The async library has a method that does what you are looking to do and is very reliable. https://github.com/caolan/async#parallel

Upvotes: 1

Related Questions