Skip to content

Instantly share code, notes, and snippets.

@micha
Forked from jjmojojjmojo/test.cljs.hl
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save micha/9671aa13cef79df9a14f to your computer and use it in GitHub Desktop.

Select an option

Save micha/9671aa13cef79df9a14f to your computer and use it in GitHub Desktop.
(page "test.html")
(defc working-set [])
(def indexed (partial map-indexed list))
(defn setup-working-set
"Initially populate the working set - normally the res"
[data]
(let [wset (map (fn [c] [c false]) data)]
(reset! working-set wset))
(prn working-set))
(defn toggle-in-working-set!
[i]
(swap! working-set update-in [i 1] not))
(setup-working-set ["T", "U", "V", "W"])
(html
(head
(title "Hoplon FTW"))
(body
(h1 "Watch and wonder!")
(div
(loop-tpl
:bindings [[i [c state]] (cell= (indexed working-set))]
(div
(h2 :text (cell= c))
(span :text (cell= (if state "picked!" "left behind!")))
(button
:text "Click it"
:click #(toggle-in-working-set! @i)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment