on
Use an interceptor to use registered coeffects; use a kv-pair to use registered effects
Re-Frame has two rules for working with registered coffects (world input) and registered effects (output to world): 1) Pull world input with (inject-cofx :coeffect-name)
in an interceptor, and 2) Call registered effects by putting a :effect-name :value
kv-pair in the returned effect map. To follow these rules, you need to know that effects can pull in a vector of interceptors. These interceptors generally change the hashmap called “coffects” before going to the effect. One type of interceptor is (inject-cofx :coeffect-name)
which pulls a interceptor-signatured function from a global registry using :coeffect-name
. This pulled function then modifies the coeffects hashmap. You also need to know that returning a hashmap with the key of a registered effect (e.g. (reg-fx :effect-name)
) will pull and run the registered function with the single given value. Useful for navigation, screen animations, and local storage updating.