 
   (broadcast! [this action args]
     (doseq [controller (keys controllers)]
-      (dispatch! this controller action args))))
+      (dispatch! this controller action args)))
+
+  (broadcast-sync! [this action args]
+    (doseq [controller (keys controllers)]
+      (dispatch-sync! this controller action args))))

  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)

(def queue (volatile! []))
(def schedule (volatile! []))

(defn- queue-update! [f]
  (vswap! queue conj f))

(defn- schedule-update! [f]
  (vswap! schedule conj f)
  (js/requestAnimationFrame #(when-not (zero? (count @schedule)) (f))))


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

(deftype Reconciler [state controllers meta]
  Object
