Hello, I need to show timers (something like "3 mi...
# compose
Hello, I need to show timers (something like "3 minutes ago") inside complex elements inside a LazyColumn. What's the best way to refresh those timers every minute? Do I need to run one background task that will refresh all the LazyColumn view tree? Or run a background task for every single LazyColumn elements that will only refresh the Text view showing the timer?
just use coroutine.
I’d use one mutable state for current time that is updated once a minute and then use derived state calculating relative time right where it is needed. I believe this should limit recompositions to a minimum needed.
Here’s an example of how I’ve done it before. Anytime you want to update the UI with the current time, read the value of
within a
ProvideTime { }