 (defui App
   static om/IQuery
   (query [this]
-    [:resources])
+    [{:root-resources (om/get-query ResourceList)}])
   Object
   (render [this]
-    (dom/div nil (resource-list (:resources (om/props this))))))
+    (dom/div nil (resource-list (:root-resources (om/props this))))))
 
-; env is more than just the app-atom
-(defn read [{:keys [state] :as env} key params]
+
+(defmulti read (fn [env key params] key))
+
+(defmethod read :default [{:keys [state] :as env} key params]
   (let [data @state]
-    (if-let [[_ resources] (find data key)]
-      {:value resources}
+    (if-let [[_ value] (find data key)]
+      {:value value}
       {:value :not-found})))
+
+(defmethod read :root-resources [{:keys [state] :as env} key params]
+  {:value {:resources (:value (read env :resources params))}})
+
 
 (defn mutate [{:keys [state] :as env} key params]
   {:action #(swap! state update-in [:resources] conj {:name "New!"})}

          {:name "pivnet-develop"}
          ]}))

(declare reconciler)


(defui ResourceItem
  Object
  (render [this]
    (dom/li nil (:name (om/props this)))))

(def resource-item (om/factory ResourceItem {:keyfn :name}))

(defui ResourceList
  Object
  (render [this]
    (dom/ul nil
      (map resource-item (om/props this))
      (dom/button
        #js {:onClick #(om/transact! reconciler '[(add-resource)])}
        "Add"))))

  (:require [goog.dom :as gdom]
            [om.next :as om :refer-macros [defui]]
            [om.dom :as dom]))

(enable-console-print!)


(def app-state
