Try to add localstorage middleware. Failed because keywords are turned into strings. Duh!
This commit is contained in:
parent
a7f5aca490
commit
c4b3e0f8f8
|
@ -1,10 +1,10 @@
|
||||||
(ns todomvc.handlers
|
(ns todomvc.handlers
|
||||||
(:require
|
(:require
|
||||||
[todomvc.db :refer [default-value valid-schema? get-local-storage]]
|
[todomvc.db :refer [default-value valid-schema?
|
||||||
|
get-local-storage set-local-storage!]]
|
||||||
[re-frame.core :refer [register-pure-handler
|
[re-frame.core :refer [register-pure-handler
|
||||||
path after
|
path after
|
||||||
trim-v
|
trim-v debug]]))
|
||||||
debug validate]]))
|
|
||||||
|
|
||||||
|
|
||||||
;; -- Middleware --------------------------------------------------------------
|
;; -- Middleware --------------------------------------------------------------
|
||||||
|
@ -12,6 +12,8 @@
|
||||||
;; 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 check-schema (after valid-schema?))
|
||||||
|
|
||||||
|
(def write-ls (after set-local-storage!))
|
||||||
|
|
||||||
;; middleware for any handler which manipulates todos.
|
;; middleware for any handler which manipulates todos.
|
||||||
(def todo-middleware [check-schema (path [:todos]) debug trim-v])
|
(def todo-middleware [check-schema (path [:todos]) debug trim-v])
|
||||||
|
|
||||||
|
@ -22,7 +24,7 @@
|
||||||
[todos]
|
[todos]
|
||||||
(if (empty? todos)
|
(if (empty? todos)
|
||||||
0
|
0
|
||||||
(inc (apply max (keys todos))))) ;; hillariously inefficient, but yeah
|
(inc (last (keys todos)))))
|
||||||
|
|
||||||
|
|
||||||
;; -- Handlers ----------------------------------------------------------------
|
;; -- Handlers ----------------------------------------------------------------
|
||||||
|
@ -37,7 +39,7 @@
|
||||||
|
|
||||||
(register-pure-handler ;; handlers changes the footer filter
|
(register-pure-handler ;; handlers changes the footer filter
|
||||||
:set-showing ;; event-id
|
:set-showing ;; event-id
|
||||||
[check-schema debug trim-v] ;; middleware (wraps the handler)
|
[write-ls check-schema debug trim-v] ;; middleware (wraps the handler)
|
||||||
(fn ;; handler
|
(fn ;; handler
|
||||||
[db [filter-kw]]
|
[db [filter-kw]]
|
||||||
(assoc db :showing filter-kw)))
|
(assoc db :showing filter-kw)))
|
||||||
|
|
Loading…
Reference in New Issue