Skip to content

Instantly share code, notes, and snippets.

@mooz
Created May 8, 2010 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mooz/394548 to your computer and use it in GitHub Desktop.
Save mooz/394548 to your computer and use it in GitHub Desktop.
function coro(process) {
var g = process(function resume(v) { g.send(v); });
g.next();
}
coro(function (resume) {
var a = yield setTimeout(function () {
resume("FOO!");
}, 2000);
alert(a);
var b = yield setTimeout(function () {
resume("BAR!");
}, 1000);
alert(b);
});
alert("HMM!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment