itnoles
11/18/2022, 11:55 PMvar timer by remember { mutableStateOf(time) }
LaunchedEffect(key1 = timer) {
if (timer > 0) {
delay(1000L)
timer -= 1000L
}
}
Is this is best way to do timer per seconds?Francesc
11/19/2022, 12:48 AMStylianos Gakis
11/19/2022, 8:33 AMval timer by produceState(initialValue = 0L) {
while (isActive) {
delay(1.seconds)
value += 1.seconds.inWholeMilliseconds
}
}
This is what produceState exists for, gives you initial value, and a coroutine scope in which you can do stuff in.