Fork me on GitHub
#fulcro
<
2022-05-21
>
tony.kay00:05:29

Load will do that for you with :marker

cl_j01:05:43

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 ...))

tony.kay02:05:35

No, fulcro does not render on swap

cl_j02:05:29

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))
 ...
  )

cl_j02:05:06

the only difference is that i extracted the swap line to letfn

tony.kay06:05:45

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.

tony.kay06:05:05

The way you've written it you should be passing env to your helper, but I commonly recommend writing helpers that work on the state map so that you can compose them together into a single swap. I'd say just make sure you're passing the right argument to your outer function