Skip to content

Instantly share code, notes, and snippets.

@jjmojojjmojo
Last active August 29, 2015 14:21
Show Gist options
  • Save jjmojojjmojo/f114d1b48a46a5e8b2ea to your computer and use it in GitHub Desktop.
Save jjmojojjmojo/f114d1b48a46a5e8b2ea to your computer and use it in GitHub Desktop.
Hoplon toggle button array
(page "test.html")
(defc working-set [])
(defn setup-working-set
"Initially populate the working set - normally the result of an async call"
[data]
(let [wset (map (fn [c] [c false]) data)]
(reset! working-set wset))
(prn working-set))
(setup-working-set ["T", "U", "V", "W"])
(html
(head
(title "Hoplon FTW"))
(body
(h1 "Watch and wonder!")
(div
(loop-tpl
:bindings [[c state] working-set]
(div
(h2 :text (cell= c))
(span :text (cell= (if state "picked!" "left behind!")))
(button
:text "Click it"
:click #(swap! state not)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment