Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // functionality is broken across many code snippets wrapped in a function
- var array_of_functions = [
- function() {
- // do something 1
- },
- function() {
- // do something 2
- },
- function() {
- // do something 3
- },
- function() {
- // do something 4
- }
- ];
- // Start executing the snippets immediately with a 25 ms lag between each snippet.
- setTimeout(function() {
- // Get the first code snippet and remove it from the array
- var item = array_of_functions.shift();
- // execute the next code snippet after 25 ms from now
- if (array_of_functions.length > 0) {
- setTimeout(arguments.callee, 25);
- }
- // if the item isn't undefined, execute it
- if(item){
- item.call();
- }
- }, 0);
Add Comment
Please, Sign In to add comment