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

otakusenpai

10/19/2018, 7:48 AM
I'm using ticker function to create a repeating task which repeats after 1 min. I have the receive part of the code done. But the problem is in the apply part. Where do I sent the function which calls the apply code of the ticker? The ticker itself is running inside a while loop.
Copy code
val tickUpdater = ticker(60,0)
while(true) {
   // do something
   withTImeoutOrNull(60) { tickUpdater.receive() }
}
Where do I apply this function
Copy code
suspend fun updateTickList() {
   tickUpdater.apply {
       // do something
   }
}
d

dave08

10/19/2018, 9:52 AM
Haven't used it yet, but maybe
tickerUpdater.consumeEach { updateSomething() }
?
2 Views