Pergunta de entrevista da empresa Canva

How would you allow for multiple promises to be processed at the same time?

Respostas da entrevista

Sigiloso

17 de jun. de 2020

Promise.all()

1

Sigiloso

18 de out. de 2020

Actually Promise.all is not the only one, just depend on what you need, if your promises need to execute with a depedency grade, so Promise.all will work fine, but if you just want to execute all of them, so you should use Promise.allSettled , so will return a promise when all the passed promises were resolved or rejected, so Promise.all will stop de execution if any of the promise failed.

Sigiloso

17 de nov. de 2022

Promise.all() good for getting results in parallel - doesn't complete till all promises complete the other way to do is is through for( const x of y) {...} or x.foreach(y...) or even x.reduce(y...), which will exec in series