Skip to content

Instantly share code, notes, and snippets.

@domenic
Last active August 29, 2015 14:00
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 domenic/11309309 to your computer and use it in GitHub Desktop.
Save domenic/11309309 to your computer and use it in GitHub Desktop.
async function*
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
@domenic
Copy link
Author

domenic commented Apr 26, 2014

Sync pull: generators
Async pull: generators of promises (above)

Sync push: ???
Async push: observables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment