I didn’t actually play with generator functions myself too much because I didn’t have to. I let CAF handle generator functions for vue-concurrency. But as I understand it, it depends on the consumer of the generator function how it is handling it things — specifically, when it is calling for next()
. The consumer can do then()
on the last value and only afterwards call for next()
or it could do something else entirely. CAF is waiting for promises to resolve which makes the generator function to behave like async function: https://github.com/getify/CAF/blob/master/src/caf.src.js#L224
ember-concurrency goes a bit further and it also manages some automatic task cancelling and XHR handling as part of generator function handling, which is something vue-concurrency could borrow as well.