simple javascript queue that deal with sequential processing
-
create an instance of Queue.
var queue = new Queue();
-
add processes to the instance.
queue.add(function(next){ appendResult("first process"); next(); }).add(function(next){ setTimeout(function(){ appendResult("second process"); next(); },1000) });
or pass your processes directly to the construtor: var queue = new Queue([ function(){...}, function(){...}, ]);
-
run the processes.
queue.execute(function(){ alert("all done!") })