René
05/16/2019, 11:36 AMsuspend fun magic(token: String) {}
fun tokenMagic(refreshToken: String, work: (String)->Unit) =
runBlocking {
fetchToken(refreshToken)
}?.let(work::invoke)
fun example() {
tokenMagic("42") { token ->
magic(token) // magic should be only called from a coroutine
}
}
I would like to execute "work" within a runBlocking block, so that I doesn't need to add a runBlocking statment for each usage of tokenMagic
marstran
05/16/2019, 11:39 AMsuspend
modifier: work: suspend (String) -> Unit
René
05/16/2019, 11:40 AMmarstran
05/16/2019, 11:43 AM