(shutdown! task)(subscribe! ticker k f)Registers an effect function f under key k to be regularly executed by the ticker.
ticker: The ticker instance returned by ticker.k: A unique key for the effect.f: A zero-argument function to be executed.Registers an effect function `f` under key `k` to be regularly executed by the ticker. - `ticker`: The ticker instance returned by `ticker`. - `k`: A unique key for the effect. - `f`: A zero-argument function to be executed.
(task f
&
{:keys [initial-delay interval thread-factory]
:or {interval (* 15 60 1000)
initial-delay 0
thread-factory default-thread-factory}})Schedules a recurring execution of the zero-argument function f in its own thread.
Options (as keywords):
:initial-delay (default 0): delay before first execution in milliseconds.:interval (default 15 minutes): interval in milliseconds between executions.
Returns a ScheduledExecutorService that executes f at the specified interval.
The scheduled thread will log any exception thrown by f and continue recurring.
Example:
;; Schedule a task to print every 5 seconds
(def exec (task #(println "tick") :interval 5000))
;; To cancel, call .shutdown on execSchedules a recurring execution of the zero-argument function `f` in its own thread. Options (as keywords): - `:initial-delay` (default 0): delay before first execution in milliseconds. - `:interval` (default 15 minutes): interval in milliseconds between executions. Returns a ScheduledExecutorService that executes `f` at the specified interval. The scheduled thread will log any exception thrown by `f` and continue recurring. Example: ;; Schedule a task to print every 5 seconds (def exec (task #(println "tick") :interval 5000)) ;; To cancel, call .shutdown on `exec`
(thread-factory fmt)(ticker & {:as opts})Creates a ticker component that runs registered effects at a regular interval (in ms). Options:
:interval (default 15 minutes): interval in milliseconds between executions.
Returns a component that implements com/start and com/stop and holds effect functions under ::effects.
Usage:
(def t (com/start (ticker {:interval 1000})))
(add-effect! t ::foo #(prn :yolo))
(com/stop t)Creates a ticker component that runs registered effects at a regular interval (in ms).
Options:
- `:interval` (default 15 minutes): interval in milliseconds between executions.
Returns a component that implements `com/start` and `com/stop` and holds effect functions under `::effects`.
Usage:
(def t (com/start (ticker {:interval 1000})))
(add-effect! t ::foo #(prn :yolo))
(com/stop t)(unsubscribe! ticker k)Removes the effect function associated with key k from the ticker.
ticker: The ticker instance.k: The effect key to remove.Removes the effect function associated with key `k` from the ticker. - `ticker`: The ticker instance. - `k`: The effect key to remove.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |