This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-21
Channels
- # announcements (17)
- # babashka (2)
- # beginners (51)
- # calva (14)
- # clojure (30)
- # clojure-europe (12)
- # clojure-uk (3)
- # clojurescript (22)
- # cursive (10)
- # defnpodcast (1)
- # etaoin (1)
- # fulcro (7)
- # graalvm-mobile (3)
- # music (1)
- # obb (4)
- # podcasts-discuss (1)
- # sci (2)
- # shadow-cljs (37)
- # spacemacs (3)
- # xtdb (16)
Can I use letfn
around defmutation
, I see sometimes it does not work
(letfn [(set-busy? [{:keys [state ref]} busy?]
(swap! state update-in ref assoc :ui/busy? busy?))]
(defmutation ...))
I am not sure if it's because of swap, because this works as expected
(defmutation some-action
[_]
(action [{:keys [ref state]}]
(swap! state update-in ref assoc :ui/busy? true))
...
)
So in principle, yes, if you use that within the action of the mutation, then it is ok. My guess is that your double swapping or something to where your original value is getting overwritten by an outer swap. Not sure without seeing the rest of your code. But in general, if you're trying to do a busy marker for mutation, then you should just be able to do calls of that within action and ok-action.