Created
October 21, 2011 07:42
-
-
Save christianschmizz/1303310 to your computer and use it in GitHub Desktop.
Build and process the queue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var i = 0, queue = []; | |
// Put some functions at the queue | |
queue.push(function(data, next) { console.log(++i, data); setTimeout(next, 1000); }); | |
queue.push(function(data, next) { console.log(++i, data); setTimeout(next, 1000); }); | |
queue.push(function(data, next) { console.log(++i, data); setTimeout(next, 1000); }); | |
queue.push(function(data, next) { console.log(++i, data); setTimeout(next, 1000); }); | |
process(queue, { | |
stopCallback: function(data) { console.log('stop callback', data); }, // optional | |
callback: function(data) { console.log('callback', data); } | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment