For promise & co-routine, I've used bluebird npm package in NodeJs.
Can someone please help in understanding the behavior of below code when promise is getting resolved multiple times.
Question:
-
What will happens to coroutine when the promise resolved for multiple times?
-
Will the second yield will be affected by the multiple yield of first.
const bluebird = require("bluebird");
function func1() { return new bluebird((resolve, reject) => { let c = 0; SetInterval(() => { c++; let cc = c; console.log(`c=${c}`); resolve(true); }, 1000); }); } let run1 = bluebird.coroutine(function*() { try { yield func1(); yield func1(); yield func1(); yield func1(); } catch (e) { console.dir(e); } });
via dearvivekkumar
No comments:
Post a Comment