Skip to content

Instantly share code, notes, and snippets.

@nooga
Last active September 28, 2015 15:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nooga/2da3bff215f0f7d2adb3 to your computer and use it in GitHub Desktop.
Save nooga/2da3bff215f0f7d2adb3 to your computer and use it in GitHub Desktop.
(defonce state (atom {:items [{:name "apple" :tasty true}
{:name "shoe" :tasty false}
{:name "glue" :tasty true}]}))
(defn toggle-tasty [name]
;... swap! :items
)
(defn item [i]
[:div [:span (:name i)]
[:input {:type "checkbox" :checked (:tasty i) :on-change (fn [x] (toggle-tasty (:name i)))}]
(defn items [its]
[:div
(for [i its]
[item i])])
(reagent/render-component [items (:items @state)]
(. js/document (getElementById "app")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment