Programming languages enthusiast. Author of Learn Type Driven Development: https://www.packtpub.com/application-development/learn-type-driven-development
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...
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 !
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Christopher, great and timely reminder of the danger of async. However I may be missing something but, about your last example:
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
...It's an example, the methods in question could be fetching data.
For example
getBasket
could fill the store'sbasket
state variable needed byfetchOptions
. 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 !