          :get-state-ch get-state-ch}))
     om/IRenderState
     (render-state [_ state]
-      (let [root (get (:grids cursor) "root")]
-        (if root
-          (dom/div #js {:style #js {:fontFamily "monospace"}}
-                   (om/build grid-view root {:state (assoc state :ns "root")}))
-          (dom/div nil "loading..."))))))
+      (dom/div #js {:style #js {:fontFamily "monospace"}}
+               (om/build grid-view "root" {:state state})))))
         
 (om/root app-view app-state
   {:target (. js/document (getElementById "app"))})

                (dom/td nil
                 (dom/table nil
                  (apply dom/tr nil
                         (om/build-all cell-view (get cursor "beats") {:state state}))))
                (dom/td nil
                        (when (= "grid" (get cursor "type"))
                          (let [id (get cursor "id")
                                root (om/root-cursor app-state)
                                grids (:grids root)
                                sub-grid (get grids id)
                                sub-state {:set-state-ch (:set-state-ch state)
                                           :get-state-ch (:get-state-ch state)
                                           :ns id}]
                            (om/build grid-view sub-grid {:state sub-state})))))))))

                          
                            

(defn grid-view [cursor owner]
  (reify
    om/IInitState
    (init-state [_]
      {:grid-expanded false})
    om/IRenderState
    (render-state [_ state]
      (dom/div #js {:style #js {:borderLeft "solid 3px #ccc"
                                :paddingLeft "10px"}}
               (if-not (:grid-expanded state)
                 (dom/div nil (dom/p #js {:onClick #(om/set-state! owner :grid-expanded true)
                                          :style #js {:color "#999"}}
                                     (str "[+] " (:ns state))))
                 (dom/div nil (dom/p #js {:onClick #(om/set-state! owner :grid-expanded false)
                                          :style #js {:color "#999"}}
                                     (str "[-] " (:ns state)))
                          (apply dom/table nil
                                 (om/build-all track-view (get cursor "tracks")
                                               {:state state}))))))))

(defn app-view [cursor _]
  (reify


(defonce app-state (atom {:grids {}}))

(defn grids []
  (om/ref-cursor (:grids (om/root-cursor app-state))))

(defn cell-view [{:keys [cursor id]} _]
  (reify
    om/IRenderState
    (render-state [_ state]
      (dom/td #js {:onClick #(do
                               (om/update! cursor [(mod (inc (first cursor)) 2)])
                               (go (>! (:set-state-ch state) id)))
                   :style #js {:width "20px"
                               :fontSize "20px"}}
             (str " " (first cursor))))))

(declare grid-view)

(defn track-view [{:keys [cursor id]} owner]
  (reify
    om/IInitState
    (init-state [_]
