Add explanation on schema
This commit is contained in:
parent
c88ad9feb4
commit
aae13840ba
|
@ -2,12 +2,16 @@
|
||||||
(:require
|
(:require
|
||||||
[schema.core :as s :include-macros true]))
|
[schema.core :as s :include-macros true]))
|
||||||
|
|
||||||
|
;; -- Schema ------------------------------------------------------------------
|
||||||
(def default-initial-state
|
;;
|
||||||
{:todos (sorted-map) ;; todo ids are the keys (for sort)
|
;; A Primatic Schema for the contents of `app-db`. At any time we can validate
|
||||||
:showing :all ;; one of :all :done or :active
|
;; the contents of 'app-db' using valid schema.
|
||||||
})
|
;;
|
||||||
|
;; Only event handlers can mutate "app-db", so after each handler runs we'll
|
||||||
|
;; want to revalidate.
|
||||||
|
;;
|
||||||
|
;; In handlers.cljs, notice how we use middleware to achieve that.
|
||||||
|
;;
|
||||||
|
|
||||||
(def schema
|
(def schema
|
||||||
{:todos (s/both (s/pred map?) (s/pred sorted?))
|
{:todos (s/both (s/pred map?) (s/pred sorted?))
|
||||||
|
@ -20,5 +24,15 @@
|
||||||
(s/validate schema db))
|
(s/validate schema db))
|
||||||
|
|
||||||
|
|
||||||
|
;; -- Default Value ----------------------------------------------------------
|
||||||
|
;;
|
||||||
|
(def default-value
|
||||||
|
{:todos (sorted-map) ;; todo ids are the keys
|
||||||
|
:showing :all
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue