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

Colton Idle

01/05/2021, 1:36 PM
I want to perform an event every 10 minutes so I'm following this code. https://stackoverflow.com/questions/54827455/how-to-implement-timer-with-kotlin-coroutines
Copy code
val tickerChannel = ticker(delayMillis = 10 * 60_000, initialDelayMillis = 0)

repeat(10) {
    tickerChannel.receive()
    println("TIMER SUCCESS")
}
I want it to repeat forever though. I'm probably missing something dumb, but can I signify forever somehow, or do I have to use Integer.MAX_VALUE?
w

wasyl

01/05/2021, 2:02 PM
how about
while(true)
?
c

Colton Idle

01/05/2021, 2:58 PM
So just wrapping the repeat with a while statement. Or do you mean replacing the repeat statement with while?
w

wasyl

01/05/2021, 3:03 PM
Replacing repeat with while, that’s how I understand you want to it to work — receive from ticker channel forever
4 Views