Liking cljdoc? Tell your friends :D

Interceptors

Interceptors in re-dash work similar to re-frame, so head over there for detailed documentation

Built-in

Out the box, re-dash supports the following interceptors

debug

Log useful information during event execution, see debugging

inject-cofx

Inject coeffects into the cofx map that we can use inside our event handlers, see coeffects

path

An interceptor which acts somewhat like clojure.core/update-in, in the sense that the event handler is given a specific part of app-db to change, not all of app-db, see path

Creating your own

An interceptor is simply a map with the following structure:

{:id     :my-cool-interceptor
 :before before-fn
 :after  after-fn}

There's also a convenience function provided to build an interceptor:

(rd/->interceptor
  :my-cool-interceptor
  before-fn
  after-fn)

before-fn and after-fn are functions with one argument which is the event context. See re-frame's documentation for more detail.

Global Interceptors

Registers the given interceptor as a global interceptor. Global interceptors are included in the processing chain of every event.

Also see: Global Interceptors

Example

Add this somewhere early on in your app's startup, like in main

(rd/reg-global-interceptor
  (rd/debug))

Can you improve this documentation?Edit on GitHub

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

× close