Skip to content

Instantly share code, notes, and snippets.

@amacdougall
Last active August 29, 2015 14:03
Show Gist options
  • Save amacdougall/80c073adb4e06738d452 to your computer and use it in GitHub Desktop.
Save amacdougall/80c073adb4e06738d452 to your computer and use it in GitHub Desktop.
;; Bogey (sets the :current boolean for each player)
(defn select-player [app player]
(om/transact! app :players (fn [players]
(mapv (fn [p]
(assoc p :current (= p @player)))
players))))
;; Birdie -- but I feel like it's more cognitive load
(defn select-player [app player]
(let [set-current #(assoc % :current (= % @player))]
(om/transact! app :players #(mapv set-current %))))
; NOTE: See core.cljs for the usage with (partial select-player app player). That part is cool.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment