Skip to content

Instantly share code, notes, and snippets.

@adambene
Last active March 8, 2018 00:10
Show Gist options
  • Save adambene/88515f851cababd0bd72779c295369a1 to your computer and use it in GitHub Desktop.
Save adambene/88515f851cababd0bd72779c295369a1 to your computer and use it in GitHub Desktop.
Delays With Coroutines in JavaScript
function* delays() {
let a = yield delay(800, "Hello, I'm an");
console.log(a);
let b = yield delay(400, "async coroutine!");
console.log(b);
}
// call it
coroutine()(delays());
// for full implementation see: https://gist.github.com/adambene/b3de67803e634be8f7d6baa273b5f447
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment