Add explanation on schema
This commit is contained in:
parent
c88ad9feb4
commit
aae13840ba
|
@ -2,12 +2,16 @@
|
|||
(:require
|
||||
[schema.core :as s :include-macros true]))
|
||||
|
||||
|
||||
(def default-initial-state
|
||||
{:todos (sorted-map) ;; todo ids are the keys (for sort)
|
||||
:showing :all ;; one of :all :done or :active
|
||||
})
|
||||
|
||||
;; -- Schema ------------------------------------------------------------------
|
||||
;;
|
||||
;; A Primatic Schema for the contents of `app-db`. At any time we can validate
|
||||
;; 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
|
||||
{:todos (s/both (s/pred map?) (s/pred sorted?))
|
||||
|
@ -20,5 +24,15 @@
|
|||
(s/validate schema db))
|
||||
|
||||
|
||||
;; -- Default Value ----------------------------------------------------------
|
||||
;;
|
||||
(def default-value
|
||||
{:todos (sorted-map) ;; todo ids are the keys
|
||||
:showing :all
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue