       (r/wrap (get @items entry)
               swap! items assoc entry)])])
 
+(defn stream [items]
+  [:ul
+   (for [[id entry] (reverse @items)]
+     ^{:key id}
+     (when-not (:deleted entry)
+       [:li
+        (case (:type entry)
+          "story" [story (r/wrap entry swap! assoc items id)]
+          "comment" [comment (r/wrap entry swap! assoc items id) true]
+          [:p "Cannot render item"])]))])
+
 ;; -------------------------
 ;; Views
 (defmulti page #(:render-view (deref %)))

              (base/stories-binder
               (base/item-cache-fn app-state [:cache]))))

(defonce new-synced
  (base/bind! app-state [:stream] base/max-item
              (fn [data path msg]
                (let [[event key val] msg
                      child-path (conj path key)
                      add-change-fn #(do
                                       (swap! data assoc-in child-path val)
                                       (base/bind! data (conj path :item)
                                                   (base/id->fbref val)
                                                   base/story-binder))]
                  (case event
                    :value (add-change-fn)
                    (.log js/console (clj->js [event key val])))))))

;; ------------------------
;; Components

      [:p "Cannot render item"])))

(defmethod page :stream [state]
  (when-let [entries (get-in @state [:stream :items])]
    [stream (r/wrap entries swap! assoc-in state [:stream :items])]))

(defn main-page [state]
  [:div.main
