Last active
August 29, 2015 14:00
-
-
Save domenic/11309309 to your computer and use it in GitHub Desktop.
async function*
This file contains 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
async function* myAsyncGenerator() { | |
console.log("hi"); | |
await Q.delay(1000); | |
var a = yield 10; | |
await Q.delay(100); | |
var b = yield 20; | |
throw new Error('boo'); | |
return; | |
} | |
var thingy = myAsyncGenerator(); | |
thingy.next('ignored') // promise for { value: 10, done: false } which fulfills after 1s | |
thingy.next('a') // promise for { value: 20, done: false } which fulfills after 2s | |
thingy.next('b'); // promise rejected with Error<'boo'> after 2s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sync pull: generators
Async pull: generators of promises (above)
Sync push: ???
Async push: observables