Rather accurate timers for the browser.
All timers are handled asynchronously by a worker
, which offers some benefits over scheduling them
on the main thread. For instance, timers scheduled on the main thread are throttled when the tab is
inactive.
Rather accurate timers for the browser. All timers are handled asynchronously by a [[worker]], which offers some benefits over scheduling them on the main thread. For instance, timers scheduled on the main thread are throttled when the tab is inactive.
(epoch)
Returns the current Unix epoch in milliseconds.
Returns the current Unix epoch in milliseconds.
See worker
.
See [[worker]].
(cancel this token)
Cancels a timer by using its token.
See [[in]] and [[every]].
Cancels a timer by using its token. See [[in]] and [[every]].
(every this millis f)
(every this millis f on-lag)
Executes f
every millis
milliseconds.
Offers drift protection so that each run is performed at a fixed interval, regarless of how long the previous run took. For instance, starting at 0 with an interval of 5000 milliseconds, the timeline should be: 5000, 10000, 15000, 20000, ...
If a run takes more time than the given interval, execution is lagging, in which case any further scheduling is stopped and
on-lag
(if provided) is called with 1 argument: a negative value denotating the lag in milliseconds (eg. -143 means "143 milliseconds
late").
Returns a token for cancellation (akin to [[in]]).
Executes `f` every `millis` milliseconds. Offers drift protection so that each run is performed at a fixed interval, regarless of how long the previous run took. For instance, starting at 0 with an interval of 5000 milliseconds, the timeline should be: 5000, 10000, 15000, 20000, ... If a run takes more time than the given interval, execution is lagging, in which case any further scheduling is stopped and `on-lag` (if provided) is called with 1 argument: a negative value denotating the lag in milliseconds (eg. -143 means "143 milliseconds late"). Returns a token for cancellation (akin to [[in]]).
(in this millis f)
Executes f
in millis
milliseconds using the given worker.
Returns a token which can be used in [[cancel]] for effectively clearing this timer.
Executes `f` in `millis` milliseconds using the given worker. Returns a token which can be used in [[cancel]] for effectively clearing this timer.
(now)
High resolution timestamp garanteed to be monotonically increasing, usually preferred over epoch
.
Returns the number of milliseconds elapsed since the time origin. Fractional part, if present, represents fractions of a millisecond and should be accurate to 5 microseconds.
High resolution timestamp garanteed to be monotonically increasing, usually preferred over [[epoch]]. Returns the number of milliseconds elapsed since the time origin. Fractional part, if present, represents fractions of a millisecond and should be accurate to 5 microseconds. Cf. [Time origin in MDN](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp#The_time_origin)
(worker)
Creates a new worker which can be used for scheduling.
Creates a new worker which can be used for scheduling.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close