 (ns gc-api-browser.core
-  (:require-macros [cljs.core.async.macros :refer [go]])
+  (:require-macros [cljs.core.async.macros :refer [go-loop]])
   (:require [cognitect.transit :as transit]
             [om.core :as om :include-macros true]
             [om.dom :as dom :include-macros true]

            (js/setTimeout
              (fn []
                (load-app-state! app)
                (set-default-headers! app)))
            (go (while true
                  (let [state (async/<! throttled)]
                    (store/write! state)))))
          om/IRender
          (render [_]
            (if (get-in app [:request :schema])

  (om/transact! app [:request :headers]
                (fn [headers] (if (empty? headers) default-headers headers))))

(defn sync-app-state! [c]
  (let [throttled (throttle c 300)]
    (go-loop []
      (when-some [state (async/<! throttled)]
        (store/write! state)
        (recur)))))

(defn main []
  (let [app-state-chan (async/chan (async/sliding-buffer 1))]
    (om/root
      (fn [app _]
        (reify
