   IHash
   (-hash [this] (goog/getUid this))
 
-  IReset
-  (-reset! [_ newv]
-    (-swap! state (constantly newv)))
-
-  ISwap
-  (-swap! [this f]
-    (reset! state (f (-deref state))))
-  (-swap! [this f a]
-    (reset! state (f (-deref state) a)))
-  (-swap! [this f a b]
-    (reset! state (f (-deref state) a b)))
-  (-swap! [this f a b rest]
-    (reset! state (apply f (-deref state) a b rest)))
-
   IPrintWithWriter
   (-pr-writer [this writer opts]
     (-write writer "#object [scrum.reconciler.Reconciler ")

(ns scrum.reconciler)

(defprotocol IReconciler
  (dispatch! [this controller action args])
  (broadcast! [this action args]))

(deftype Reconciler [state controllers meta]
  Object


  IReconciler
  (dispatch! [this cname action args]
    (queue-update! #(let [ctrl (get controllers cname)
                          cstate (get % cname)]
                      (->> cstate
                        (ctrl action args)
                        (assoc % cname))))
    (schedule-update!
     #(swap! state (fn [state]
                     (let [new-state (reduce (fn [state f] (f state)) state @queue)]
                       (vreset! queue [])
                       (vreset! schedule [])
                       new-state)))))

  (dispatch-sync! [this cname action args]
    (swap! state #(let [ctrl (get controllers cname)
                        cstate (get % cname)]
                    (->> cstate
                      (ctrl action args)
