     (close! to-repl)))
 
 (defn reset-repl! [state]
-  (when-let [repl (:repl @state)]
-    (close! (:from-repl repl))
-    (close! (:to-repl repl)))
+  (when-let [{:keys [from-repl to-repl]} (:repl @state)]
+    (close! from-repl)
+    (close! to-repl))
 
   (let [{:keys [to-repl from-repl]} (repl-thread/repl-thread)
         to-eval                     (chan)]
-    (repl-event-loop state from-repl)
-    (repl-eval-loop to-eval to-repl from-repl)
     (swap! state #(-> %
                       (merge default-state)
                       (assoc :repl {:to-repl   to-eval
-                                    :from-repl from-repl})))))
+                                    :from-repl from-repl})))
+    (repl-event-loop state from-repl)
+    (repl-eval-loop to-eval to-repl from-repl)))
 
 (defn eval-str! [expression]
   (let [{:keys [to-repl]} (:repl @state)
-        expression        (some-> expression trim)]
+        expression        (some-> expression str/trim)]
     (when (and (some? to-repl) (some? expression))
       (put! to-repl expression))))
 

   [cljs.core.async.macros :refer [go go-loop]]))

(def default-state
  {:ns      nil
   :input   ""
   :cursor  0
   :history (sorted-map)})

  [:div.card-output
   [:div.card-data
    (into [:pre.line]
          (for [line (str/split output #"\n")]
            [:code.line line]))]
   [:hr.border]])

