how do I switch between dispatchers using `async`...
# coroutines
m
how do I switch between dispatchers using
async
and
await
?
z
You can pass a dispatcher to
async
, that dispatcher will be used to run the block.
await
uses the dispatcher in the current context, which you can change with
withContext
.
m
nice thank u
z
To clarify,
await
doesn't really "use" a dispatcher, it just suspends the current coroutine.
👍 1
b
Yeah, as he's describing
await
will receive the value in the current context, so there MAY be benefits if you have to utilize that value inside that context as well.
👍 1