Last active
March 8, 2018 00:10
-
-
Save adambene/88515f851cababd0bd72779c295369a1 to your computer and use it in GitHub Desktop.
Delays With Coroutines in JavaScript
This file contains hidden or 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
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