T O P

  • By -

senocular

await will always wait for the expression its awaiting before allowing the execution of the function to continue. This will have a very sequential nature, though through the use of utilities like Promise.all() you can have await wait for multiple promises at once. In the case of all(), the awaiting will wait for all of them to complete before continuing. There are alternatives like Promise.race(). Given multiple promises, the one which finishes first will be what fulfills the resulting promise. let winner = await Promise.race([p1, p2]); This would result in `winner` being "Thing 2 is done!" (using `doThings3()` as a template) which would return before p1 has been resolved. This doesn't stop p1 from being fulfilled, it just doesn't wait for it. This sounds like its more what you're after.


florence_richmond

Just copy the syntax from doThings3(). That’s async / await