Interceptor chain implementation.
Ported from re-frame/interceptor.cljc with JVM compatibility.
An interceptor is a map with optional keys:
Context is a map containing:
Interceptor chain implementation. Ported from re-frame/interceptor.cljc with JVM compatibility. An interceptor is a map with optional keys: - :id - keyword identifier - :before - fn [context] -> context (pre-processing) - :after - fn [context] -> context (post-processing) Context is a map containing: - :coeffects - input data (including :event and :db) - :effects - output data (side effects to perform) - :queue - interceptors yet to execute - :stack - interceptors already executed (for :after phase)
(->interceptor & {:keys [id before after] :as m})Create an interceptor from components.
(->interceptor :id :debug :before (fn [ctx] (println (:event (:coeffects ctx))) ctx) :after (fn [ctx] (println (:effects ctx)) ctx))
Create an interceptor from components. (->interceptor :id :debug :before (fn [ctx] (println (:event (:coeffects ctx))) ctx) :after (fn [ctx] (println (:effects ctx)) ctx))
(->timed-interceptor & {:keys [_id _before _after _timeout-ms] :as m})Create an interceptor with a timeout budget on :before and/or :after.
If either phase exceeds timeout-ms, it is cancelled and the context passes through unchanged (graceful degradation). This prevents any single interceptor from hanging the entire event dispatch chain.
Usage: (->timed-interceptor :id :hk/smart-search-enrichment :timeout-ms 15000 :after (fn [ctx] ...expensive enrichment...))
Delegates to hive-weave.timed/->timed-interceptor via requiring-resolve.
Create an interceptor with a timeout budget on :before and/or :after.
If either phase exceeds timeout-ms, it is cancelled and the context
passes through unchanged (graceful degradation). This prevents any
single interceptor from hanging the entire event dispatch chain.
Usage:
(->timed-interceptor
:id :hk/smart-search-enrichment
:timeout-ms 15000
:after (fn [ctx] ...expensive enrichment...))
Delegates to hive-weave.timed/->timed-interceptor via requiring-resolve.Log event and effects for debugging.
Log event and effects for debugging.
(enqueue context interceptors)Add interceptors to the queue.
Add interceptors to the queue.
(execute context)Execute interceptor chain synchronously.
Returns final context with :effects populated.
Execute interceptor chain synchronously. 1. Run all :before fns (queue order) 2. Run all :after fns (reverse order) Returns final context with :effects populated.
(execute-async context)Execute interceptor chain asynchronously.
Returns a core.async channel that will receive the final context.
Supports async interceptors that return channels.
Execute interceptor chain asynchronously. Returns a core.async channel that will receive the final context. Supports async interceptors that return channels.
(path p)Interceptor that focuses handler on a path within db.
(reg-event-db :counter/inc [(path [:counters :main])] (fn [counter _] (inc counter)))
Interceptor that focuses handler on a path within db. (reg-event-db :counter/inc [(path [:counters :main])] (fn [counter _] (inc counter)))
Remove event id from event vector, leaving just args. [:user/login {:email ...}] -> [{:email ...}]
Remove event id from event vector, leaving just args.
[:user/login {:email ...}] -> [{:email ...}]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 |