        (take 4)
        (str/join)
        (str/upper-case)))
-
-(defn join-room [id]
-  (let [fb-item (m/get-in fb-root [(str/lower-case id) :messages])]
-    (reset! fb-messages fb-item)
-    (bind-to-ratom messages fb-item)))
 
 ;; -- Subscriptions ---------
 

   :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 []

     [:button {:type "submit"} "Send"]]))

(defn show-messages []
  (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 -----------------

