DEV Community

Discussion on: Don't make that function async.

Collapse
clovis1122 profile image
José Clovis Ramírez de la Rosa Author • Edited on

Yo Nic,

Async/await looks beautiful when it's done in that way (to make async code look and feel as if it was sync). It makes it easier to deal with.

I think that starting long async functions as early as possible is a great idea. Sadly I don't have any straightforward example about starting a long process while still doing something useful with the current execution. When you do it, it's usually just firing and waiting for other async requests.

Occasionally on the Client, we fire a request to get/save some data, save the request promise in a variable, and perform some small checks before launching an UI update event. At the end we await the request to launch another UI update event with the outcome (success/failure).