   :username-input
   (fn [db _]
     (reaction (:username @db))))
+
+(register-sub
+  :current-chat-room
+  (fn [db _]
+    (reaction (:chat-room @db))))
+
+(register-sub
+  :chat-room-messages
+  (fn [db _]
+    (reaction (:messages @db))))
 
 ;; -- Event Handlers --------
 

            [matchbox.async :as ma]
            [matchbox.core :as m])
  (:require-macros [reagent.ratom :refer [reaction]]
                   [cljs.core.async.macros :refer [go go-loop]])
  (:import goog.History))

;; -- REPLACE with your own DB location ---------
(def firebase-io-root "https://shining-torch-2145.firebaseIO.com")
;; ----------------------------------------------

(def initial-state
  {:chat-room nil
   :messages []
   :username (str "Guest" (rand-int 100))})

(defonce chat-room (reagent/atom nil))

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

  (fn [db [_ value]]
    (assoc db :username value)))

(register-handler
  :join-chat-room
  (fn [db [_ room-id]]
    (join-room room-id)
    (assoc db :chat-room room-id)))

(register-handler
  :send-message
  (fn [db [_ username message chat-room]]
    (m/conj-in! fb-root [(-> chat-room (str/lower-case) (keyword))
                         :messages]
                [username message])
    db))

;; -- View Components -------

(defn username-input []
