 
 ;;main component
 
-(defn handler [f res]
-  (f res))
-
-(defn load-data [comm]
-  (GET "http://localhost:3000/comments"
-    {:response-format :json
-     :keywords? true
-     :handler (partial handler #(put! comm [:init %] ))
-     :error-handler error-handler}))
-
-;;put! comm [:add {:author "ar" :text "tr"}]
-;;#(put! comm [:add {:author "ra" :text "rt"}])
+(defn handle-comm-event [t app val]
+  (case t
+    :add (om/transact! app :comments #(conj % val))
+    :init (om/update! app {:comments val})
+    nil))
 
 (defn render-comment-list [{:keys [comments]}]
   (apply dom/ul #js {:className "commentList"}
     (om/build-all comment-view comments)))
 
-(defn handle-event [t app val]
-  (case t
-    :add (om/transact! app :comments #(conj % val))
-    :init (om/update! app {:comments val})
-    nil))
 
 (defn comment-box [app owner]
     (reify

     :format :json
     :handler simple-handler
     :error-handler error-handler}))

(defn add-comment [evt owner {:keys [author text comm] :as data}]
  (.preventDefault evt)

           (load-data comm)
           (while true
            (let [ [t value] (<! comm)]
              (handle-comm-event t app value))))))

    om/IRenderState
    (render-state [_ {:keys [comm]}]
