Created
January 31, 2019 19:20
-
-
Save xantiagoma/385d8ec0a8f29e656fd33dd44e47c75d to your computer and use it in GitHub Desktop.
Like Co library to execute Generatos and use yield as await
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 execute(generator, yieldValue) { | |
| let next = generator.next(yieldValue); | |
| if (!next.done) { | |
| next.value.then( | |
| result => execute(generator, result), | |
| err => generator.throw(err) | |
| ); | |
| } else { | |
| alert(next.value); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment