 
 ; Load all items from API
 (edn-xhr {:method "GET"
-          :url "http://localhost:3000/items"
+          :path "/items"
           :on-complete (fn [data]
                          (d/transact! conn data))})
 

(defmulti mutate om/dispatch)

; Add a single item
(defmethod mutate 'items/add
  [{:keys [state]} _ entity]
  {:value {:keys [:items]}
   :action (fn [] (d/transact! state [entity]))})

; Scavenger items list
(defui ItemsList


(enable-console-print!)

(def api-url "http://localhost:3000")

; Utility function to send XHR requests with correct content type and parse
; the EDN response appropriately.
; TODO: Use core.async to avoid on-complete callback
(defn edn-xhr [{:keys [method path data on-complete]}]
  (let [xhr (XhrIo.)
        url (str api-url path)]
    (events/listen xhr goog.net.EventType.COMPLETE
      (fn [e]
        (on-complete (reader/read-string (.getResponseText xhr)))))
