Davide Giuseppe Farella
10/06/2020, 9:37 AMsuspend fun getThree() =
withContext(IO) {
val one = async { getOne() }
val two = async { getTwo() }
one.await() + two.await()
}
would be better to be wrapper in a coroutineScope
or would the withContext
be enough?orafaaraujo
10/06/2020, 9:43 AMwithContext
is more to switch between dispatchersgetThree()
will be called, so I think to switch the dispatcher to IO is fine 🙂gildor
10/06/2020, 9:46 AMusing a scope you will be protected against possible leaksIt’s true, but it’s it’s also true for withContext, because with context is create a scope, same as coroutine scope, but also switch dispatcher
Davide Giuseppe Farella
10/06/2020, 9:47 AMgildor
10/06/2020, 9:47 AMDavide Giuseppe Farella
10/06/2020, 4:29 PM