Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Atom refactoring
(defn update-my-atom [a name]
(let [new-state (assoc-in @a [:foo :bar] merge {:name name})]
(swap! a (fn [old] new-state))))
;; refactored into:
(defn get-new-state [state name]
(assoc-in state [:foo :bar] merge {:name name}))
(defn update-my-atom [a name]
(swap! a get-new-state name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment