6 ms·
+1 for generators. As a former PHP developer, I jumped into using generators that return promises in io.js (as well as es6 classes), and the code reads very muc
by LePetitDev 11y ago
+1 for generators. As a former PHP developer, I jumped into using generators that return promises in io.js (as well as es6 classes), and the code reads very much like PHP code, except all of the i/o is now asynchronous.
- esailija 11y agoThere is no benefit of io being async in itself until you have many users. The immediate and more accessible benefit is speeding up individual requests due to the ease at which you can perfom io in parallel. But if you just sprinkle await/yield everywhere (which everyone unfortunately does), you don't even get this benefit.
- brentburgoyne 11y agoSure you can. let [a, b] = await Promise.all([asyncA(), asyncB()])
- esailija 11y agoI am referring to usage of generators without promises (or rather code that uses generators in a way that it wouldnt matter if promises or thunks were used). And even then I didn't say that you couldn't, even when using promises and generators together most people make their code unneceasarily sequential.