Lightweight scheduling library.
Lightweight scheduling library.
The clock used to determine 'now'; you can override it with binding
for
testing purposes.
The clock used to determine 'now'; you can override it with `binding` for testing purposes.
(chime-at times f)
(chime-at times
f
{:keys [error-handler on-finished thread-factory clock]
:or {error-handler default-error-handler
thread-factory default-thread-factory
clock *clock*}})
Calls f
with the current time at every time in the times
sequence.
(:require [chime.core :as chime])
(:import [java.time Instant])
(let [now (Instant/now)]
(chime/chime-at [(.plusSeconds now 2)
(.plusSeconds now 4)]
(fn [time]
(println "Chiming at" time)))
Returns an AutoCloseable that you can .close
to stop the schedule.
You can also deref the return value to wait for the schedule to finish.
Providing a custom thread-factory
is supported, but optional (see chime.core/default-thread-factory
).
Providing a custom clock
is supported, but optional (see chime.core/utc-clock
).
When the schedule is either cancelled or finished, will call the on-finished
handler.
You can pass an error-handler to chime-at
- a function that takes the exception as an argument.
Return truthy from this function to continue the schedule, falsy to cancel it.
By default, Chime will log the error and continue the schedule.
Calls `f` with the current time at every time in the `times` sequence. ``` (:require [chime.core :as chime]) (:import [java.time Instant]) (let [now (Instant/now)] (chime/chime-at [(.plusSeconds now 2) (.plusSeconds now 4)] (fn [time] (println "Chiming at" time))) ``` Returns an AutoCloseable that you can `.close` to stop the schedule. You can also deref the return value to wait for the schedule to finish. Providing a custom `thread-factory` is supported, but optional (see `chime.core/default-thread-factory`). Providing a custom `clock` is supported, but optional (see `chime.core/utc-clock`). When the schedule is either cancelled or finished, will call the `on-finished` handler. You can pass an error-handler to `chime-at` - a function that takes the exception as an argument. Return truthy from this function to continue the schedule, falsy to cancel it. By default, Chime will log the error and continue the schedule.
(now)
(now clock)
Returns a date time for the current instant.
Returns a date time for the current instant.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close