This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-06
Channels
- # announcements (2)
- # architecture (2)
- # aws (18)
- # babashka (7)
- # beginners (149)
- # bristol-clojurians (4)
- # calva (11)
- # chlorine-clover (1)
- # cider (8)
- # clj-kondo (2)
- # cljdoc (2)
- # cljsrn (2)
- # clojure (186)
- # clojure-canada (3)
- # clojure-europe (3)
- # clojure-gamedev (5)
- # clojure-italy (1)
- # clojure-nl (13)
- # clojure-norway (4)
- # clojure-spec (25)
- # clojure-uk (32)
- # clojurescript (75)
- # core-async (2)
- # cursive (16)
- # data-science (3)
- # datomic (20)
- # docker (1)
- # emacs (26)
- # fulcro (7)
- # graphql (1)
- # incanter (1)
- # leiningen (1)
- # luminus (7)
- # malli (7)
- # mount (11)
- # off-topic (19)
- # pathom (15)
- # re-frame (9)
- # reagent (9)
- # remote-jobs (4)
- # ring-swagger (4)
- # shadow-cljs (63)
- # spacemacs (11)
- # sql (2)
- # vscode (7)
I remember reading some stuff about why get-in
style subscriptions aren’t what you usually want — can anyone point me to where that is written down?
TLDR is subscriptions are cached, if you subscribe to (get-in db [:a :b :c])
your component will re-render every time :a changes (or maybe it’s every time db
changes). Done properly, it will re-render only when :c changes.
Since :a changes whenever anything under :as changes, that’s a lot of extra and unnecessary re-renders.
> if you subscribe to (get-in db [:a :b :c]) your component will re-render every time :a changes
That's not true, I think. The sub will be re-run, yes. But the component will be re-rendered iff (get-in db [:a :b :c])
value is changed.
You know what, I think you’re right, now that I think about it. That’s a “fact” I got in my head a long time ago and I’ve never really challenged it, but you’re right, there’s no way for re-frame to track the state at every step in the “get-in” path. I withdraw my comment.
People should ignore me and just read the “A Final FAQ” section of the link you posted in your thread.