Yes, but they don't actually appear to yield to the event loop. It looks like they're synchronous by default. I tried it with the following setup:
function* process() {
const items = new Array(100).fill(null);
for (const i of items) {
waitSync(50);
yield i;
}
}
for (const i of process()) {
loopCount.innerText = Number(loopCount.innerText) + 1;
console.log(i);
}
Thank you, Ondřej!
Mission accomplished!
Thanks, Paul 🙏
Thanks! Very glad it was helpful. 👍
Thanks, Hagenek! That means a lot.
I appreciate that! Glad it was helpful.
That's something I definitely didn't know before you said something... so I'm glad you did!
Yes, but they don't actually appear to yield to the event loop. It looks like they're synchronous by default. I tried it with the following setup:
function* process() { const items = new Array(100).fill(null); for (const i of items) { waitSync(50); yield i; } } for (const i of process()) { loopCount.innerText = Number(loopCount.innerText) + 1; console.log(i); }Good callout. The minimum delay that kicks in with
setTimeout()s will drive you nuts if you don't know why it's happening.Good catch. Got it updated. Thanks!