https://kotlinlang.org logo
#coroutines
Title
# coroutines
r

rook

04/29/2019, 7:49 PM
What causes the IDE to recommend using
withContext(Dispatchers.Default)
over
async
? Is
withContext
more optimal, somehow?
s

serebit

04/29/2019, 7:50 PM
Using
async { }.await()
. Having the two function calls is unnecessary if you aren’t storing the Deferred and having it awaited elsewhere
r

rook

04/29/2019, 7:51 PM
I didn’t even realize that it had removed the need for the
await()
call, thanks!
👍🏿 1
l

louiscad

04/29/2019, 8:21 PM
Also, `async`+`await` will cancel the parent scope if a crash occurs, which may not be the behavior you want if you use it like
withContext
.
r

rook

04/29/2019, 8:49 PM
Good to know, thank you.
g

gildor

04/29/2019, 11:22 PM
What is you use case? You just switch dispatcher?
2 Views