Fork me on GitHub

Load will do that for you with :marker


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


No, fulcro does not render on swap


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


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


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.


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