(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 kee-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 `kee-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))) ```
(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))) ```
(reg-event-db id handler)
(reg-event-db id interceptors handler)
Exactly same signature as re-frame.core/reg-event-db
. Use this version if you want kee-frame logging and spec validation.
re-frame.core/trim-v
interceptor is also applied.
Exactly same signature as `re-frame.core/reg-event-db`. Use this version if you want kee-frame logging and spec validation. `re-frame.core/trim-v` interceptor is also applied.
(reg-event-fx id handler)
(reg-event-fx id interceptors handler)
Exactly same signature as re-frame.core/reg-event-fx
. Use this version if you want kee-frame logging and spec validation.
re-frame.core/trim-v
interceptor is also applied.
Exactly same signature as `re-frame.core/reg-event-fx`. Use this version if you want kee-frame logging and spec validation. `re-frame.core/trim-v` interceptor is also applied.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close