Andrea Giuliano
08/27/2020, 10:14 AMinterface MyGuy {
suspend fun CoroutineScope.doSomething()
}
or is there a better way when it comes to interface declaration?andylamax
08/27/2020, 10:16 AMAndrea Giuliano
08/27/2020, 10:17 AMgildor
08/27/2020, 10:18 AMAndrea Giuliano
08/27/2020, 10:20 AMsuspend fun doSomething() {
launch {} // not possible
}
that’s because I’m not in a scope, so how to I make launch be running in the caller scope?andylamax
08/27/2020, 10:20 AMgildor
08/27/2020, 10:21 AMgildor
08/27/2020, 10:21 AMgildor
08/27/2020, 10:21 AMsuspend fun doSomething() {
coroutineScope {
launch {} // Possible!
}
}
gildor
08/27/2020, 10:22 AMAndrea Giuliano
08/27/2020, 10:22 AMgildor
08/27/2020, 10:23 AMgildor
08/27/2020, 10:23 AMandylamax
08/27/2020, 10:25 AMsuspend function doSomenthing() = coroutineScope {
launch{
// do crazy things in here
}
}
Just in case I need the instance of the calling scope, if not, I just call the functiongildor
08/27/2020, 10:26 AMsuspend function doSomenthing() = // do crazy things in here
Andrea Giuliano
08/27/2020, 11:06 AM