      [:button {:type "submit"} "Send"]]))
 
 (defn show-messages []
-  [:div#messages
-   (for [[[k v] index] (map vector (take-last 30 @messages) (range))]
-     ^{:key (str "message-" index)}
-     (let [{:keys [username message]} v]
-       [:div [:span.username username] ": " [:span.message message]]))])
+  (let [messages (subscribe [:chat-room-messages])]
+    [:div#messages
+     (for [[[k v] index] (map vector @messages (range))]
+       (let [{:keys [username message]} v]
+         ^{:key (str "message-" index)}
+         [:div [:span.username username] ": " [:span.message message]]))]))
 
 ;; -- Views -----------------
 

   :messages []
   :username (str "Guest" (rand-int 100))})

(defonce fb-messages (atom nil))
(defonce messages (reagent/atom []))

;; -- Firebase helpers ------

(defn bind-to-ratom [ratom ref & [korks]]
  (let [ch (ma/listen-to< ref korks :value)]
    (go-loop [[key val] (<! ch)]
      (reset! ratom val)
      (recur (<! ch)))))

(defn firebase-swap! [fb-ref f & args]
  (apply m/swap! fb-ref f args))

;; -- Helpers ---------------

(defn- random-four-characters []

       (take 4)
       (str/join)
       (str/upper-case)))

;; -- Subscriptions ---------

