Back
chime-at (clj)
(source)function
(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.