https://kotlinlang.org logo
#coroutines
Title
# coroutines
p

Pablo

05/06/2021, 2:31 PM
I found this :
Copy code
val timer = (0..MyInterval) 
 .asSequence()
 .asFlow()
 .onEach { delay(1_000) }

timer.collect { //do something }
But how do I stop the timer as I do with if(whatever) foo = false?
g

gildor

05/06/2021, 2:41 PM
this example doesn’t really make sense for me, looks unnecessary over-complicated
👍🏽 1
n

natario1

05/07/2021, 9:12 AM
An extra problem here is that if the collecting code has another delay() or takes a lot of time, the timing of the timer will be affected. Depending on your use case this might be an issue.
👍🏽 1
3 Views