Skip to content

Instantly share code, notes, and snippets.

@dtothefp
Last active December 19, 2015 14:55
Show Gist options
  • Select an option

  • Save dtothefp/7af0ace1e4486ac46266 to your computer and use it in GitHub Desktop.

Select an option

Save dtothefp/7af0ace1e4486ac46266 to your computer and use it in GitHub Desktop.
const fromSpawn = spawn(function *() {
let rejValFirst, rejValSecond, resValLast;
try {
rejValFirst = yield new Promise((res, rej) => {
setTimeout(rej.bind(null, 'blaaa...first rejected!!!'), 1000);
});
} catch (err) {
console.error('Inside spawn error', err);
}
try {
rejValSecond = yield new Promise((res, rej) => {
setTimeout(rej.bind(null, 'blaaa...second rejected!!!'), 1000);
});
} catch (err) {
console.error('Inside spawn error', err);
}
try {
resValLast = yield new Promise((res, rej) => {
setTimeout(res.bind(null, 'yehhhh...last resolved!!!'), 1000);
});
} catch (err) {
console.error('Inside spawn error', err);
}
console.log('End of spawn', rejValFirst, rejValSecond, resValLast);
return 'BLAAAHHHHH';
});
fromSpawn.then((data) => {
console.log('Data from spawn', data);
}).catch((err) => {
console.error('Err from spawn', err.message);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment