With new SC, is there any changes in `withContext`...
# coroutines
t
With new SC, is there any changes in
withContext
vs
async
policy or it is ok to continue using
withContext
?
CoroutineScope
sample uses
async
, not `withContext`: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-coroutine-scope/index.html
g
I think withContext is still more idiomatic and optimal solution
t
It is not quite clear how withContext is connected with parent scope - async and launch are directly tied to scope but withContext is not
k
I believe
withContext
is also very much a member of the scope. And very much like
coroutineScope
, it suspends until it’s execution is complete, which as Andrey said, it more optimal than calling eager
async {}.await()
in the same scope
g
withContext is also coroutine scope and also tied to parent scope
e
You should use async only when you need parallelism.
👌 1