 (ns todomvc.db
   (:require
     [schema.core :as s :include-macros true]))
+
 
 ;; -- Schema ------------------------------------------------------------------
 ;;

(def schema
  {:todos   (s/both (s/pred map?) (s/pred sorted?))
   :showing (s/enum :all :done :active)
   :blah (s/enum :all :done :active)   ;; add this bogus schema item in, then watch the console
   })






;; -- Local Storage  ----------------------------------------------------------
;;
;;  Set and Get

(def local-storage-key "re-frame-todomvc")

(defn get-local-storage
  []
  (let [data (.getItem js/localStorage local-storage-key)]
    (when-not (nil? data)
      (-> data (js/JSON.parse) (js->clj :keywordize-keys true)))))


(defn set-local-storage!
  [db]
  (let [data (-> db (clj->js) (js/JSON.stringify))]
    (.setItem js/localStorage local-storage-key data)))