Skip to content

Instantly share code, notes, and snippets.

@dtothefp
Last active December 19, 2015 14:27
Show Gist options
  • Save dtothefp/a4f64904244d3bff975e to your computer and use it in GitHub Desktop.
Save dtothefp/a4f64904244d3bff975e to your computer and use it in GitHub Desktop.
const fromSpawn = spawn(function *() {
let someVal;
try {
//reject a promise
someVal = yield new Promise((res, rej) => {
setTimeout(rej.bind(null, 'whatevs!!!'), 1000);
});
} catch (err) {
console.error('Inside spawn error', err);
}
//don't return anything
console.log('End of spawn', someVal);
});
fromSpawn.then((data) => {
console.log('Data from spawn', data);
}).catch((err) => {
console.error('Err from spawn', err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment