launch vs async/await
The async and launch functions that you used to perform the request and update the UI are called coroutine builder functions, functions that set up a coroutine to perform work in a certain way. launch builds a coroutine that performs the work you specify right away – in this case, calling fetchCharacterData and updating the UI.
The async coroutine builder works differently than launch in that it builds a coroutine that returns a Deferred, a type that represents work that has not been completed yet. Instead of starting the work immediately, a Deferred is a promise of work to be completed some time in the future.
The Deferred type provides a function called await that you call when you would like the work to ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access