Compose + Coroutines
Launched Effect
println("recomposing hello button")
if(value % 3 ==0) {
Text(text = "can divide by 3")
LaunchedEffect(key1 = value){
try {
println("********************")
println("current thread : ${Thread.currentThread().name}")
withContext(Dispatchers.IO){
println("IO thread? : ${Thread.currentThread().name}")
}
delay(3000)
println("ending launched effect")
}catch (e:CancellationException){
println("******Launched effect was cancelled******")
}
}
}similarly to :
val result=remember(key){calculate()}"hacks/workarounds" already in official examples
coroutine "problems"
DisposableEffect?
Coroutine outside compose
Wrong approach
Correct Approach
SharedFlow in compose
Last updated
Was this helpful?