Start to simplify todomvc

This commit is contained in:
mike-thompson-day8 2015-03-06 18:10:18 +11:00
parent 13840ed9a1
commit 9bb1b4e459

View File

@ -10,12 +10,13 @@
;; -- Middleware -------------------------------------------------------------- ;; -- Middleware --------------------------------------------------------------
;; ;;
;; checks that the structure in app-db matches the schema ;; checks that the structure in app-db matches the schema
(def check-schema (after valid-schema?)) (def schema-ok? (after valid-schema?))
;; store todos in local storage
(def write-ls-todos (after #(set-local-storage! :todos %))) (def write-ls-todos (after #(set-local-storage! :todos %)))
;; middleware for any handler which manipulates todos. ;; middleware for a handler which manipulates todos.
(def todo-middleware [check-schema (path [:todos]) write-ls-todos debug trim-v]) (def todo-middleware [schema-ok? (path :todos) write-ls-todos debug trim-v])
;; -- Helpers ----------------------------------------------------------------- ;; -- Helpers -----------------------------------------------------------------
@ -39,7 +40,7 @@
(register-handler ;; handlers changes the footer filter (register-handler ;; handlers changes the footer filter
:set-showing ;; event-id :set-showing ;; event-id
[(path [:showing]) #_write-ls check-schema debug trim-v] ;; middleware (wraps the handler) [(path :showing) check-schema debug trim-v] ;; middleware (wraps the handler)
(fn ;; handler (fn ;; handler
[db [filter-kw]] [db [filter-kw]]
filter-kw)) filter-kw))