This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-14
Channels
- # aleph (3)
- # announcements (1)
- # babashka (36)
- # babashka-sci-dev (4)
- # beginners (62)
- # biff (2)
- # calva (13)
- # cider (4)
- # clj-kondo (6)
- # cljdoc (17)
- # clojure (142)
- # clojure-dev (6)
- # clojure-europe (62)
- # clojurescript (20)
- # core-async (26)
- # cursive (18)
- # data-oriented-programming (9)
- # data-science (1)
- # datahike (18)
- # events (4)
- # fulcro (4)
- # graalvm (2)
- # hyperfiddle (15)
- # interop (1)
- # jobs-discuss (8)
- # leiningen (2)
- # lsp (91)
- # malli (1)
- # missionary (11)
- # nbb (65)
- # off-topic (50)
- # practicalli (2)
- # programming-beginners (4)
- # re-frame (18)
- # remote-jobs (1)
- # shadow-cljs (53)
- # spacemacs (1)
- # specter (2)
- # sql (17)
- # tools-build (63)
- # web-security (1)
- # xtdb (15)
Re-com question here: why aren't my subscriptions running when I click my cloud button?
;; views.cljs
(defn cloud [cloudId]
(let [cloud (re-frame/subscribe [::subs/cloud cloudId])]
[re-com/md-icon-button
:md-icon-name (if @cloud "zmdi-cloud" "zmdi-cloud-outline")
:on-click (fn [] (re-frame/dispatch [::events/toggle-cloud cloudId]))]))
;; subs.cljs
(re-frame/reg-sub
::clouds
(fn [db]
(:clouds db)))
(re-frame/reg-sub
::cloud
:<- [::clouds]
(fn [clouds [_ cloudId]]
(nth clouds cloudId)
))
reframe-10x doesn't show that they've run, and the icon of the cloud doesn't change after I click on it, despite the app db being updated
cloud
is a true or false value that represents whether it's cloudy in a particular spot or not. I'll need to send toggle-cloud later, so sorry but I'm not at my computer
It basically does (update clouds cloudId not)
I mean, how do you use the cloud
component? Not just its direct usage, but also its parent component.
I have a clouds
component that does (map cloud (range 50))
Could that be it? The map makes a seq of clouds, but are they actually components?
And they are not components in this case - just functions. Sometimes it's ok, but not in this case as updating a single cloud will rerender the whole parent component.
Ok thanks for looking over it with me. Sorry, I'm away from my computer or I would share the code in full
I got the issue resolved by doing it this way as opposed to doing (map cloud (range 50))
:
(defn cloud [cloudId]
(let [cloud (re-frame/subscribe [::subs/cloud cloudId])]
[re-com/md-icon-button
:md-icon-name (if @cloud "zmdi-cloud" "zmdi-cloud-outline")
:on-click (fn [] (re-frame/dispatch [::events/toggle-cloud cloudId]))]))
(defn clouds []
[re-com/h-box
:src (at)
:width "100%"
:children [(for [cloudId (range 50)]
[cloud cloudId])]])