Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@domachine
Created February 3, 2016 14:19
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 domachine/b22982ec35935ec59359 to your computer and use it in GitHub Desktop.
Save domachine/b22982ec35935ec59359 to your computer and use it in GitHub Desktop.
function performingIO(done) {
console.log('Heay IO ...');
setTimeout(() => done(42), 1000);
}
function *myGenerator() {
const a = yield { fn: performingIO };
return a;
}
const it = myGenerator();
const m = it.next();
m.fn((value) => {
it.next(value); // => { value: 42, done: true }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment