diff --git a/examples/todomvc/src/todomvc/db.cljs b/examples/todomvc/src/todomvc/db.cljs index b012d64..e59e1d4 100644 --- a/examples/todomvc/src/todomvc/db.cljs +++ b/examples/todomvc/src/todomvc/db.cljs @@ -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 + }) + + + +