 
 (defn channel-list [{:keys [params data]} owner]
   (reify
+    om/IInitState
+    (init-state [_]
+      {:loading false})
+    om/IWillMount
+    (will-mount [_]
+      (when (empty? (:channels data))
+        (om/set-state! owner :loading true))
+      (go
+        (let [loc (<! (get-geolocation))]
+          (om/update! data [:geolocation] loc)
+          (let [response (<! (http/get "/api/channels" {:query-params loc}))]
+            (om/update! data [:channels] (:body response))))
+        (om/set-state! owner :loading false)
+        (om/set-state! owner :poll-interval
+          (js/setInterval
+            #(go
+               (let [loc (<! (get-geolocation))]
+                 (om/update! data [:geolocation] loc)
+                 (let [response (<! (http/get "/api/channels" {:query-params loc}))]
+                   (om/update! data [:channels] (:body response)))))
+            3000))))
+    om/IWillUnmount
+    (will-unmount [_]
+      (js/clearInterval (om/get-state owner :poll-interval)))
     om/IRenderState
     (render-state [_ {:keys [comm]}]
-      (dom/div nil
-        (apply dom/ul #js {:className "virt-list"}
-          (om/build-all list-item data {:init-state {:comm comm}}))))))
+      (if (om/get-state owner :loading)
+        (om/build loading nil)
+        (dom/div nil
+          (apply dom/ul #js {:className "virt-list"}
+            (om/build-all list-item (:channels data) {:init-state {:comm comm}})))))))
 
 (defn new-channel [_ owner]
   (reify

  (reify
    om/IInitState
    (init-state [_]
      {:comm (chan)
       :loading true})
    om/IWillMount
    (will-mount [_]
      (let [comm (om/get-state owner :comm)
            core-comm (om/get-state owner :core-comm)]
        (go
          (let [loc (<! (get-geolocation))]
            (om/update! data [:geolocation] loc)
            (let [response (<! (http/get "/api/channels" {:query-params loc}))]
              (om/update! data [:channels] (:body response))))
          (om/set-state! owner :loading false)
          (om/set-state! owner :poll-interval
            (js/setInterval
              #(go
                 (let [loc (<! (get-geolocation))]
                   (om/update! data [:geolocation] loc)
                   (let [response (<! (http/get "/api/channels" {:query-params loc}))]
                     (om/update! data [:channels] (:body response)))))
              3000))
          (while true
            (let [[msg msg-data] (<! comm)]
              (case msg

                  (om/transact! data [:channels] (fn [cs] (conj cs (:body response))))
                  (put! comm [:navigate [:back]]))
                (>! core-comm [msg msg-data])))))))
    om/IRenderState
    (render-state [_ {:keys [comm]}]
      (let [m {:init-state {:comm comm}}]
        (case page
          ::new (om/build new-channel nil m)
          ::home (om/build channel-list {:params params :data data} m))))))
