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"))]
       (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 ( 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

jhacks 2020-12-01T15:43:36.398100Z

That macro looks like the answer to my issues with code navigation in emacs for events/subs. It would also enable using imenu, since it starts with def . Are there any drawbacks to using this macro instead of directly using reg-sub, for example?