Skip to content

Instantly share code, notes, and snippets.

@jaen

jaen/sample.clj Secret

Created December 2, 2015 07:50
Show Gist options
  • Save jaen/dd22b3432581fc7ab8f5 to your computer and use it in GitHub Desktop.
Save jaen/dd22b3432581fc7ab8f5 to your computer and use it in GitHub Desktop.
(defn scoreboard-component []
(let [game-state (atom [])]
(api/get-game ...)
(fn []
[:div
[:table
[:tbody
(doall
(map-indexed (fn [idx {:keys [name min pos points]}]
[:tr
[:td name]
[:td
[:input {:on-change (fn [e]
(let [new-value (.. e -target -value)]
(swap! game-state update-in [idx] assoc :min new-value))
(.preventDefault e))
:value min}]}
[:td [:input ...]]
[:td [:input ...]]]])
@game-state))]]
[:button {:on-click (fn [e]
(api/update-game! @game-state)
(.preventDefault e))}
"Send this!"]])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment