Liking cljdoc? Tell your friends :D

helins.timer

Utilities for scheduling async operations using various APIs.

See README.

Utilities for scheduling async operations using various APIs.

See README.
raw docstring

cancel-framecljs

(cancel-frame token)

See frame.

See [[frame]].
sourceraw docstring

epochcljs

(epoch)

Returns the current Unix epoch in milliseconds.

Returns the current Unix epoch in milliseconds.
sourceraw docstring

framecljs

(frame f)

Schedules f to run when the screen is about to be refreshed. Current timestamp, as it would have been returned by now, is provided as sole argument and any time-dependent computation should rely on it.

Same timestamp is provided to all functions scheduled for a given frame so that that all computations are in sync.

Is expected to run closely to the monitor refresh rate (usually, 60 frames per second).

Does not run while the tab is not focused, as there is nothing to see, hence no frame to generate.

Returns a token which can be used to cancel this via cancel-frame.

Cf. .requestAnimationFrame

Schedules `f` to run when the screen is about to be refreshed. Current timestamp, as it would have been
returned by [[now]], is provided as sole argument and any time-dependent computation should rely on it.

Same timestamp is provided to all functions scheduled for a given frame so that that all computations are
in sync.

Is expected to run closely to the monitor refresh rate (usually, 60 frames per second).

Does not run while the tab is not focused, as there is nothing to see, hence no frame to generate.

Returns a token which can be used to cancel this via [[cancel-frame]].

Cf. [.requestAnimationFrame](https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame)
sourceraw docstring

framescljs

(frames f)

Like frame, but schedules f repeatedly for every frame.

Returns a no-arg function which can be called to cancel this. Same function is provided as a second argument to f.

Like [[frame]], but schedules `f` repeatedly for every frame.

Returns a no-arg function which can be called to cancel this. Same function is provided as a second argument
to `f`.
sourceraw docstring

ITimercljsprotocol

Scheduling something at some relatively precise point in the future.

Precision depends on current activity and can be improved by using a worker rather than the main-thread.

See README.

Scheduling something at some relatively precise point in the future.

Precision depends on current activity and can be improved by using a [[worker]] rather than the [[main-thread]].

See README.

cancelcljs

(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]].

everycljs

(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 (see [[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 (see [[in]]).

incljs

(in this millis f)

Executes f in millis milliseconds.

Returns a token which can be used in [[cancel]] for effectively clearing this timer.

Executes `f` in `millis` milliseconds.

Returns a token which can be used in [[cancel]] for effectively clearing this timer.
sourceraw docstring

main-threadcljs

Object implementing ITimer functions for scheduling on the main thread.

In the browser, usually clamped to run at once per second when the tab is inactive. This is avoided by using worker.

Object implementing [[ITimer]] functions for scheduling on the main thread.

In the browser, usually clamped to run at once per second when the tab is inactive. This is
avoided by using [[worker]].
sourceraw docstring

micro-taskcljs

(micro-task f)

Enqueues f to run asynchronously as a micro task.

See README for the difference between a regular task and a micro-task.

Enqueues `f` to run asynchronously as a micro task.

See README for the difference between a regular task and a micro-task.
sourceraw docstring

nowcljs

(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. Garanteed precision is 1 millisecond unless the user-agent deliberately tweaked this option.

Cf. Time origin in MDN

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. Garanteed precision is 1 millisecond unless the user-agent
deliberately tweaked this option.

Cf. [Time origin in MDN](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp#The_time_origin)
sourceraw docstring

taskcljs

(task f)

Enqueues f to run asynchronously as a regular task.

See README for the difference between a regular task and a micro-task.

Enqueues `f` to run asynchronously as a regular task.

See README for the difference between a regular task and a micro-task.
sourceraw docstring

Workercljs

source

workercljs

(worker)

Creates a new worker which can be used for scheduling more precisely than on the main thread.

Browser only.

See ITimer functions.

Creates a new worker which can be used for scheduling more precisely than on the main thread.

Browser only.

See [[ITimer]] functions.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close