This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-05
Channels
- # announcements (14)
- # aws (7)
- # babashka (28)
- # beginners (16)
- # calva (2)
- # cider (1)
- # clj-commons (8)
- # clj-kondo (29)
- # clojure (213)
- # clojure-europe (39)
- # clojure-losangeles (2)
- # clojure-norway (9)
- # clojure-spec (2)
- # clojurescript (11)
- # community-development (1)
- # conjure (2)
- # cursive (6)
- # datalevin (2)
- # datomic (8)
- # emacs (29)
- # events (1)
- # fulcro (22)
- # graalvm (14)
- # improve-getting-started (1)
- # jobs (1)
- # lambdaisland (5)
- # leiningen (4)
- # lsp (7)
- # malli (13)
- # meander (11)
- # membrane (13)
- # off-topic (23)
- # polylith (9)
- # re-frame (4)
- # reagent (7)
- # reitit (6)
- # releases (2)
- # sql (58)
- # testing (8)
- # tools-deps (18)
- # web-security (2)
when a component has subscriptions, is it preferable to use form-2?
(defn view
[]
(let [a @(subscribe [::a])
b @(subscribe [::b])]
[:ul
[:li (str a)]
[:li (str b)]]))
vs
(defn view
[]
(let [a (subscribe [::a])
b (subscribe [::b])]
(fn []
[:ul
[:li (str @a)]
[:li (str @b)]])))
Doesn't matter in practice because re-frame subscriptions are cached. I always use the top variant unless the component is already a form-2 one for some unrelated reason.
This is especially important if your query vector depends on parameters:
(defn view [param]
(let [a (subscribe [::a param])]
(fn []
[:div (str @a)])))
Here, the subscription will not update when the view is re-rendered with a different param! @(subscribe ...)
guards you from this.➕ 2