Clojurescript Swap!和多个关联
问题描述:
试图让一段代码更好看。Clojurescript Swap!和多个关联
我在Clojurescript如下:
(swap! app-state assoc-in [:lastresults] [])
(swap! app-state assoc-in [:error] false)
(swap! app-state assoc-in [:computing] true)
有时更多。任何想法如何在一个更清洁的多任务中变成这个。
我在看类似:
(swap! app-state assoc-in
[:lastresults] []
[:error] false
[:computing] true)
答
你不需要assoc-in
只是一个级别。这将适用于您的示例:
(swap! app-state assoc
:lastresults []
:error false
:computing true)
完美适用于我的情况。 – 2014-09-30 02:38:48