Sometime ago someone linked here a neat def-sub
macro:
(defmacro def-sub [name & args]
{:pre [(symbol? name)]}
(let [kw (keyword (ns-name *ns*) (str name "|sub"))]
`(do
(def ~name ~kw)
~(macroexpand `(rf/reg-sub ~kw ~@args)))))
And that can be done for event handlers also. I'm seriously considering starting to use that. I think the benefits are quite big: Easier code navigation (jump to definition), linter warnings when trying to use undefined event/subscription etc.
I want to use local-store and use cofx similar to this (https://github.com/day8/re-frame/blob/master/docs/Coeffects.md#another-example-of-reg-cofx) But how do I do inject-cofx with a dynamic key?
The key is user-id + something, and the user-id is loaded later
After the user-id is loaded, it's stored to DB
:db
is a key in coeffects
.
So if your user-id
is already in app-db
, then you can just extract it from the coeffects
in the interceptor.
Riight, makes sense, thanks @p-himik
Hi, just in case that you weren’t aware of it, :reclojure: conf will be held this Friday and prior to it there will be a free re-frame
workshop. Thanks
https://clojurians.slack.com/archives/C03RZRRMP/p1606828591215400