Colton Idle
09/10/2024, 9:25 AMif (progress < 100) {
CircularProgressIndicator()
LaunchedEffect(Unit) {
delay(3_000)
doEvent()
}
}
Are there cases where doEvent() would accidentally be called even if progress has reached 100? I know that in coroutines cancellation is cooperative, but not sure how all of this ties together.Stylianos Gakis
09/10/2024, 9:28 AMkotlinx.coroutines.
If you are super paranoid about this, slap in a ensureActive() in-between the two so that when delay ends, you check again if you are cancelled, and only if you are not you run the doEvent().Stylianos Gakis
09/10/2024, 9:30 AMColton Idle
09/10/2024, 9:34 AMdoEvent() if progress == 100Albert Chang
09/10/2024, 10:24 AMderivedStateOf as reading progress directly will cause a lot of unnecessary recompositions.