簡體   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