Skip to content

Instantly share code, notes, and snippets.

@MonkeyIsNull
Created January 19, 2012 04:04
Show Gist options
  • Save MonkeyIsNull/1637751 to your computer and use it in GitHub Desktop.
Save MonkeyIsNull/1637751 to your computer and use it in GitHub Desktop.
Serial Flow
// 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