vineethraj49
11/20/2019, 4:12 PMwithContext
? (I’m trying to time some functions)invokeOnCompletion
with async be a “good” ideaRory Armstrong
11/20/2019, 4:15 PMrunBlocking
?Dominaezzz
11/20/2019, 4:17 PMsikri
11/20/2019, 4:21 PMsuspend fun someFun() = withContext(<http://Dispatcher.IO|Dispatcher.IO>) {
…
}
coroutineScope
, please, use it, if you are able to call it from coroutine/suspend fun, as runBlocking
is blocking, and coroutineScope
is suspendingvineethraj49
11/20/2019, 4:23 PMwithContext
takes a parameter `block`; that block’s completion;
think of it like
try {
block()
} finally {
method()
}
Dominaezzz
11/20/2019, 4:24 PMwithContext
in try/finally, no?vineethraj49
11/20/2019, 4:26 PM