Liking cljdoc? Tell your friends :D

re-chain.core


chain-interceptorclj/s

(chain-interceptor current-event-id next-event-id)
source

collect-event-instructionsclj/s

(collect-event-instructions key step-fns)
source

collect-named-event-instructionsclj/s

(collect-named-event-instructions step-fns)
source

configure!clj/s

(configure! chain-links)

re-chain only supports the dispatch effect out of the box. To add more effects, call this function at the startup of your app.

Parameters:

chain-links: Vector of maps. Each map describes how to chain together events using a certain effect. The map should contain 3 keys:

  • :effect-present? : Is the effect present in the effects map returned from an event function?
  • :get-dispatch : Try to lookup the dispatch value from the effects map
  • :set-dispatch : Set the dispatch value in the effects map

Usage:

(chain/configure! [{:effect-present? (fn [effects] (:http-xhrio effects))
                    :get-dispatch    (fn [effects] (get-in effects [:http-xhrio :on-success]))
                    :set-dispatch    (fn [effects dispatch] (assoc-in effects [:http-xhrio :on-success] dispatch))}])
re-chain only supports the `dispatch` effect out of the box. To add more effects, call this function at the startup
of your app.

Parameters:

`chain-links`: Vector of maps. Each map describes how to chain together events using a certain effect. The map should
contain 3 keys:
- `:effect-present?` : Is the effect present in the effects map returned from an event function?
- `:get-dispatch` : Try to lookup the dispatch value from the effects map
- `:set-dispatch` : Set the dispatch value in the effects map

Usage:
```
(chain/configure! [{:effect-present? (fn [effects] (:http-xhrio effects))
                    :get-dispatch    (fn [effects] (get-in effects [:http-xhrio :on-success]))
                    :set-dispatch    (fn [effects dispatch] (assoc-in effects [:http-xhrio :on-success] dispatch))}])
```
sourceraw docstring

dispatch-empty-or-nextclj/s

(dispatch-empty-or-next effects next-event-id)
source

effect-postprocessorclj/s

(effect-postprocessor next-event-id)
source

(link-effects next-event-id event-params effects)
source

source

make-eventclj/s

(make-event next-event-id previous-event-params [_ & params])
source

reg-chainclj/s

(reg-chain id & handlers)

Register a list of re-frame fx handlers, chained together.

The chaining is done through dispatch inference. https://github.com/Day8/re-frame-http-fx is supported by default, you can easily add your own like this: https://github.com/ingesolvoll/kee-frame#configuring-chains-since-020.

Each handler's event vector is prepended with accumulated event vectors of previous handlers. So if the first handler receives [a b], and the second handler normally would receive [c], it will actually receive [a b c]. The purpose is to make all context available to the entire chain, without a complex framework or crazy scope tricks.

Parameters:

id: the id of the first re-frame event. The next events in the chain will get the same id followed by an index, so if your id is add-todo, the next one in chain will be called add-todo-1.

handlers: re-frame event handler functions, registered with re-frame.core/reg-event-fx.

Usage:

(k/reg-chain
  :load-customer-data

  (fn {ctx [customer-id]]
    {:http-xhrio {:uri    (str "/customer/" customer-id)
                  :method :get}})

  (fn [cxt [customer-id customer-data]
    (assoc-in ctx [:db :customers customer-id] customer-data)))
Register a list of re-frame fx handlers, chained together.

The chaining is done through dispatch inference. https://github.com/Day8/re-frame-http-fx is supported by default,
you can easily add your own like this: https://github.com/ingesolvoll/kee-frame#configuring-chains-since-020.

Each handler's event vector is prepended with accumulated event vectors of previous handlers. So if the first handler
receives [a b], and the second handler normally would receive [c], it will actually receive [a b c]. The purpose is
to make all context available to the entire chain, without a complex framework or crazy scope tricks.

Parameters:

`id`: the id of the first re-frame event. The next events in the chain will get the same id followed by an index, so
if your id is `add-todo`, the next one in chain will be called `add-todo-1`.

`handlers`: re-frame event handler functions, registered with `re-frame.core/reg-event-fx`.


Usage:
```
(k/reg-chain
  :load-customer-data

  (fn {ctx [customer-id]]
    {:http-xhrio {:uri    (str "/customer/" customer-id)
                  :method :get}})

  (fn [cxt [customer-id customer-data]
    (assoc-in ctx [:db :customers customer-id] customer-data)))
```
sourceraw docstring

reg-chain*clj/s

(reg-chain* id interceptors & step-fns)

Same as reg-chain, but with a vector of interceptors as the second parameter. The interceptors specified will be appended to each event's interceptors.

Same as `reg-chain`, but with a vector of interceptors as the second parameter. The interceptors specified
will be appended to each event's interceptors.
sourceraw docstring

reg-chain-namedclj/s

(reg-chain-named & handlers)

Same as reg-chain, but with manually named event handlers. Useful when you need more meaningful names in your event log.

Parameters:

handlers: pairs of id and event handler.

Usage:

(k/reg-chain-named

  :load-customer-data
  (fn [ctx [customer-id]]
    {:http-xhrio {:uri "..."}})

  :receive-customer-data
   (fn [ctx [customer-id customer-data]]
    (assoc-in ctx [:db :customers customer-id] customer-data)))
Same as `reg-chain`, but with manually named event handlers. Useful when you need more meaningful names in your
event log.

Parameters:

`handlers`: pairs of id and event handler.

Usage:
```
(k/reg-chain-named

  :load-customer-data
  (fn [ctx [customer-id]]
    {:http-xhrio {:uri "..."}})

  :receive-customer-data
   (fn [ctx [customer-id customer-data]]
    (assoc-in ctx [:db :customers customer-id] customer-data)))
```
sourceraw docstring

reg-chain-named*clj/s

(reg-chain-named* interceptors & step-fns)

Same as reg-chain-named, but with a vector of interceptors as the first parameter. The interceptors specified will be appended to each event's interceptors.

Same as `reg-chain-named`, but with a vector of interceptors as the first parameter. The interceptors specified
will be appended to each event's interceptors.
sourceraw docstring

register-chain-handlers!clj/s

(register-chain-handlers! instructions user-interceptors)
source

replace-pointersclj/s

(replace-pointers next-event effects)
source

(select-link next-event-id effects)
source

(single-valid-link effects)
source

single-valid-nextclj/s

(single-valid-next next-event-id effects)
source

step-idclj/s

(step-id event-id counter)
source

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

× close