Messing around with coroutines for first time. Is ...
# coroutines
h
Messing around with coroutines for first time. Is there a better way to implement a timer that executes a block of code every x millis? I was hoping to avoid recreating the job every time but it seems that you cannot "pause" a coroutines and start it again. Thanks in advance.
n
if (!isPaused) block()
?
g
b
I don't see what's wrong with launching a new coroutine when you restart, they are lightweight
d
If block is not
block: suspend () -> Unit
what's the point of the launch? You're not suspending at all...
g
are you doing this for the learning experience or is there any reason why you don’t want to use the fixedRateTimer-extension? https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.concurrent/fixed-rate-timer.html