DEV Community

Discussion on: The dangers of async/await

Collapse
 
yawaramin profile image
Yawar Amin

Christopher, great and timely reminder of the danger of async. However I may be missing something but, about your last example:

Although this snippet poses a problem, did you spot it? ... Poor little initBooking will have to wait for both getBasket and fetchOptions to finish before executing even though it has nothing to do with the data they'll fetch.

None of these calls are fetching any data, at least in the code as shown. They can all be run in parallel with Promise.all...

Collapse
 
christopherkade profile image
Christopher Kade

None of these calls are fetching any data

It's an example, the methods in question could be fetching data.

For example getBasket could fill the store's basket state variable needed by fetchOptions. I simply wasn't going to show the contents of these methods as they don't seem relevant to the point I'm making.

Thank you for your feedback Yawar !