Skip to content

Instantly share code, notes, and snippets.

@nicokruger
Created February 29, 2012 07:13
Show Gist options
  • Save nicokruger/1938802 to your computer and use it in GitHub Desktop.
Save nicokruger/1938802 to your computer and use it in GitHub Desktop.
async-sync-pattern
var actions = [
function () {
/* code for step 1 */
callback();
}, function () {
/* code for step 2 */
callback();
}, function () {
/* code for step 3 */
callback();
}, function () {
/* code for step 4 */
callback();
}, function(){
/* code for step 5 */
callback();
}, function () {
/* code for step 6 */
callback();
}
];
function callback() {
if (actions.length) {
actions.shift()();
} else {
console.log("Done");
}
}
callback();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment