   (:require [goog.dom :as gdom]
             [om.next :as om :refer-macros [defui]]
             [om.dom :as dom]))
+
+(enable-console-print!)
 
 
 (def app-state

(defui App
  static om/IQuery
  (query [this]
    [:resources])
  Object
  (render [this]
    (dom/div nil (resource-list (:resources (om/props this))))))

; env is more than just the app-atom
(defn read [{:keys [state] :as env} key params]
  (let [data @state]
    (if-let [[_ resources] (find data key)]
      {:value resources}
      {:value :not-found})))

(defn mutate [{:keys [state] :as env} key params]
  {:action #(swap! state update-in [:resources] conj {:name "New!"})}

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

(defui ResourceItem
  static om/IQuery
  (query [this]
    [:name])
  Object
  (render [this]
    (dom/li nil (str (:name (om/props this)) " " (:foo (om/props this))))))

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

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