Liking cljdoc? Tell your friends :D

hive.events.interceptor

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 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)
raw docstring

->interceptorclj/s

(->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))
sourceraw docstring

->timed-interceptorclj

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

debugclj/s

Log event and effects for debugging.

Log event and effects for debugging.
sourceraw docstring

enqueueclj/s

(enqueue context interceptors)

Add interceptors to the queue.

Add interceptors to the queue.
sourceraw docstring

executeclj/s

(execute context)

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 interceptor chain synchronously.

1. Run all :before fns (queue order)
2. Run all :after fns (reverse order)

Returns final context with :effects populated.
sourceraw docstring

execute-asyncclj

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

pathclj/s

(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)))
sourceraw docstring

trim-vclj/s

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

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close