Clojurescript Swap! and multiple union

An attempt to make the code more attractive.

In Clojurescript, I have the following:

(swap! app-state assoc-in [:lastresults] [])
(swap! app-state assoc-in [:error] false)
(swap! app-state assoc-in [:computing] true)


Sometimes more. Any idea on how to turn this into cleaner multitasking.

I am looking at something like:

 (swap! app-state assoc-in
      [:lastresults] []
      [:error] false
      [:computing] true)



source to share

1 answer

You don't need assoc-in

only one level. This will work for your example:

(swap! app-state assoc 
       :lastresults [] 
       :error false 
       :computing true)




All Articles