繁体   English   中英

Clojurescript交换!和多个关联

[英]Clojurescript Swap! and multiple assoc-in

试图让一段代码更好看。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM