Skip to content

Instantly share code, notes, and snippets.

@jaen

jaen/sample.clj Secret

Created December 2, 2015 07:50
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
(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