re-frame

https://github.com/Day8/re-frame/blob/master/docs/README.md https://github.com/Day8/re-frame/blob/master/docs/External-Resources.md
rap1ds 2020-12-01T06:47:34.393800Z

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)))))

rap1ds 2020-12-01T06:48:34.394Z

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.

rap1ds 2020-12-01T10:22:49.395300Z

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?

rap1ds 2020-12-01T10:23:23.395500Z

The key is user-id + something, and the user-id is loaded later

rap1ds 2020-12-01T10:24:40.395700Z

After the user-id is loaded, it's stored to DB

p-himik 2020-12-01T11:02:59.395900Z

:db is a key in coeffects.

p-himik 2020-12-01T11:03:35.396100Z

So if your user-id is already in app-db, then you can just extract it from the coeffects in the interceptor.

rap1ds 2020-12-01T11:13:01.396400Z

Riight, makes sense, thanks @p-himik

dotemacs 2020-12-01T13:44:22.397800Z

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

🎉 4