Created
April 30, 2012 16:43
-
-
Save renepardon/2559934 to your computer and use it in GitHub Desktop.
For those who need a queue for different reasons ;)
This file contains hidden or 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
// Initializations. | |
var theQueue = $({}); | |
var elements = [1, 2, 3, 4, 5, 6]; | |
// Loop through all elements and add a function to the stack for every element. | |
$.each(elements, function(index, item) | |
{ | |
theQueue.queue('stack', function(next) | |
{ | |
// Do some processing here.. | |
console.log('item: ' + item); | |
setTimeout(function() { next(); }, 1000); | |
}); | |
}); | |
// Executes every function within the stack after excactly one second. | |
theQueue.dequeue('stack'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment