      (message m))])
 
 (defn demo []
-  [:div
-   [:input {:type "text" :id "input" :value "Enter text to reverse!"}]
-   [:button {:type "button" :on-click oonclick} "Open"]
-   [:button {:type "button" :on-click sonclick} "Send"]
-   [:button {:type "button" :on-click conclick} "Close"]
-   [message-list]])
+  (let [val (r/atom "")]
+    (fn []
+      [:div
+       [:input {:type        "text"
+                :value       @val
+                :placeholder "Enter text to reverse!"
+                :on-change   #(reset! val (-> % .-target .-value))}]
+       [:button {:type     "button"
+                 :on-click oonclick}
+        "Open"]
+       [:button {:type     "button"
+                 :on-click (partial sonclick @val)}
+        "Send"]
+       [:button {:type "button" :on-click conclick} "Close"]
+       [message-list]])))
 
 (defn start []
   (r/render-component


    (reset! socket websocket)))

(defn sonclick [event]
  (let [input (element "input")
        text  (.-value input)]
    (.send @socket text)
    (add-message! "sent" (str ">>> " text))))

(defn conclick [event]
  (.close @socket 1000 "Close button clicked"))

(ns chatapp.core
  (:require [reagent.core :as r]))

(def app-state (r/atom {:messages [{:style "init" :message "initial message"}]}))

