And then I wrote a timer:
# compose
c
And then I wrote a timer:
1
Recently stumbled upon a really annoying issue. I wrote a timer. The way my timer works is, I launch a coroutine every time I land on this screen, if it exists I kill it but I honestly kind of take care of killing it all the time. I have a, probably bad, compose architecture where my timer is wrapped inside of a scaffold and the bottom button on the scaffold should just be enabled when the timer ends. So far, so good. When I tried to hoist the state of my timer, so now instead of being inside of my content I started observing the timer state outside of the scaffold so I could do something like if ( time <= LocalTime.Min ) false else true and have my scaffold bottom button enabled or not. But even then I was changing the value of my timer mutableLiveData inside of my ViewModel and I could see the timer was running nothing was changing. What happened was that, thanks to my ignorance, I hoisted the state and passed down the timer value only. I still don’t know how to explain this but I would expect that if state would change then all composables under this state would recompose, which now I believe was a false truth. Can someone shed light on this issue? So in the end my timer only works if I pass this state all the way down like @Composable fun Timer(timer: State<LocalTime>) instead of timer: LocalTime. I need some time to reproduce this if there is interest.