https://kotlinlang.org logo
#compose
Title
# compose
j

Jonathan

11/10/2023, 2:32 PM
I’m trying to implement a Timer in Jetpack Compose. I’ve created a function that will return a flow that will emit at a specified rate, that I will use to update my UI. My questions is are flows safe to be
remembered
or are they light weight enough to create on the fly?
z

Zach Klippenstein (he/him) [MOD]

11/10/2023, 3:34 PM
It’s not a question of “weight”, it’s a question of identity. If you don’t remember them, you’ll end up cancelling the collection of the old one and starting collection of the new one on every recomposition.
j

Jonathan

11/10/2023, 3:35 PM
I actually just ran into this issue.. Thank you for the response.
3 Views