Created
January 19, 2012 04:04
-
-
Save MonkeyIsNull/1637751 to your computer and use it in GitHub Desktop.
Serial Flow
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
// flow in serial | |
var queue = [ | |
function (msg) { | |
console.log(msg); | |
next("second please..."); | |
}, | |
function (msg) { | |
console.log(msg); | |
console.log("in second"); | |
next("third please..."); | |
}, | |
function (msg) { | |
console.log(msg); | |
console.log("in third"); | |
next("fourth please..."); | |
}, | |
function (msg) { | |
console.log(msg); | |
console.log("in fourth"); | |
next("done - not called"); | |
} | |
]; | |
function next(msg) { | |
var item = queue.shift(); | |
if(item) { | |
item(msg); | |
} | |
} | |
next("kick off!!!"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment