-
-
Save mynomoto/c128da6dcaacd76d9796 to your computer and use it in GitHub Desktop.
Update state
This file contains 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 "index.html" | |
(:require | |
[estimate-work.elements :as e] | |
[estimate-work.elements.nav :as nav] | |
[estimate-work.elements.estimate :as estimate])) | |
(defc state | |
[{:data "foo"} | |
{:data "bingz"} | |
{:data ""} | |
{:data "bar"} | |
{:data ""}]) | |
(defn prepare-values | |
"Filter empty values, then add one empty on the end." | |
[values] | |
(conj (filterv #(seq (:data (last %))) (map-indexed (fn [idx v] [idx v]) values)) [(count values) {:data ""}])) | |
; (swap! state prepare-values) | |
(defc= prepared-values | |
(prepare-values state)) | |
(cell= (prn :state state)) | |
(cell= (prn :preparede-values prepared-values)) | |
(e/outer-dom | |
(loop-tpl :bindings [[idx {data :data}] prepared-values] | |
[(input | |
:value data | |
:change #(swap! state assoc-in [@idx :data] @%) | |
:type "text") (br)])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment