-
-
Save micha/9671aa13cef79df9a14f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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