isRepeating
Indicates whether this timer instance calls its callback repeatedly at a given delay.
let isRepeating: Bool
Indicates whether this timer instance calls its callback repeatedly at a given delay.
let isRepeating: Bool
import JavaScriptKit
Swift framework to interact with JavaScript through WebAssembly.
final class JSTimer
This timer is an abstraction over setInterval
/ clearInterval
and setTimeout
/ clearTimeout
JavaScript functions. It intentionally doesn’t match the JavaScript API, as a special care is needed to hold a reference to the timer closure and to call JSClosure.release()
on it when the timer is deallocated. As a user, you have to hold a reference to a JSTimer
instance for it to stay valid. The JSTimer
API is also intentionally trivial, the timer is started right away, and the only way to invalidate the timer is to bring the reference count of the JSTimer
instance to zero. For invalidation you should either store the timer in an optional property and assign nil
to it, or deallocate the object that owns the timer.
@frozen struct Bool
A value type whose instances are either true
or false
.
init(millisecondsDelay: Double, isRepeating: Bool = false, callback: @escaping () -> ())
Creates a new timer instance that calls setInterval
or setTimeout
JavaScript functions for you under the hood.