Liking cljdoc? Tell your friends :D

chime.core

Lightweight scheduling library.

Lightweight scheduling library.
raw docstring

*clock*clj

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.
sourceraw docstring

chime-atclj

(chime-at times f)
(chime-at times f {:keys [error-handler on-finished]})

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.

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.

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.
sourceraw docstring

periodic-seqclj

(periodic-seq start duration-or-period)
source

without-past-timesclj

(without-past-times times)
(without-past-times times now)
source

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

× close