I've tried to implement timer methods similar to t...
# announcements
h
I've tried to implement timer methods similar to those in JavaScript using
kotlin.concurrent.timer
.
Copy code
fun setInterval(millis: Long,
                action: () -> Unit) = timer("setInterval", true, millis, millis) { action() }

fun setTimeout(millis: Long,
               action: () -> Unit) = timer("setTimeout", true, millis, 0) { action() }

fun setImmediate(millis: Long,
                 action: () -> Unit) = timer("setImmediate", true, 0, 0) { action() }
Unfortunately
timer()
requires the
period
parameter to be
> 0
(i.e. the last
0
in
setTimout()
and
setImmediate()
).