 (defmulti control (fn [action] action))
 
 (defmethod control :init []
-  initial-state)
+  {:state initial-state})
+
+(defmethod control :load [_ [key]]
+  {:local-storage {:op :get
+                   :key key
+                   :on-success :load-ready}})
+
+(defmethod control :load-ready [_ [counter]]
+  {:state (int counter)})
+
+(defmethod control :save [_ [key] counter]
+  {:local-storage {:op :set
+                   :value counter
+                   :key key}})
 
 (defmethod control :inc [_ _ counter]
-  (inc counter))
+  (let [next-counter (inc counter)]
+    {:state next-counter
+     :local-storage {:op :set
+                     :value next-counter
+                     :key :count}}))
 
 (defmethod control :dec [_ _ counter]
-  (dec counter))
+  (let [next-counter (dec counter)]
+    {:state next-counter
+     :local-storage {:op :set
+                     :value next-counter
+                     :key :count}}))
 
 
 ;;



;;
;; start up
;;

;; create Reconciler instance
(defonce reconciler
  (scrum/reconciler {:state (atom {})
                     :controllers {:counter control}}))

;; initialize controllers
(defonce init-ctrl (scrum/broadcast-sync! reconciler :init))

;; render
(rum/mount (Counter reconciler)
           (. js/document (getElementById "app")))

(ns counter.core
  (:require [rum.core :as rum]
            [scrum.core :as scrum]
            [goog.dom :as dom]))

;;
;; define controller & action handlers
