      [:p (str (get files box))])])
 
 (defn app []
-  (let [state (r/atom init-state-m)]
+  (let [eval-state (cljs.js/empty-state load-namespace)
+        app-state (r/atom init-state-m)]
+    (defn eval! []
+      (eval-active eval-state @app-state (partial swap! app-state on-eval)))
     (fn []
       [:div
-       [:button {:on-click #(do-eval @state (partial swap! state update :boxes insert :below (:active-box @state)))}
+       [:button {:on-click eval!}
         "Click me"]
-       [:p (str @state)]
-       (boxes (:files @state) (:boxes @state) true)])))
+       [:p (str @app-state)]
+       (boxes (:files @app-state) (:boxes @app-state) true)])))
 
 
 

        (recur (zip/next loc))))))


(defn init-state [state]
  (assoc-in state [:cljs.analyzer/namespaces 'cljs.user]
            (analyzer-state 'fugue.api)))

(def state (cljs.js/empty-state init-state))

(def eval-settings
  {:eval cljs.js/js-eval
   :context :statement})

(defn eval-str [source load-fn cb]
  (cljs.js/eval-str state source nil (assoc eval-settings :load load-fn) cb))

(defn do-eval [state cb]
  (let [text (get-in state [:files (:active-box state)])
        load-fn (fn [m cb]
                  (if-let [source (get-in state [:files (str (:name m))])]
                    (cb {:lang :clj :source source})
                    (cb nil)))]
    (eval-str text load-fn cb)))

(defn boxes [files box is-row]
  [:div {:style {:display "flex"


(def init-state-m
  {:boxes '(1 (2 3))
   :active 1
   :next-id 4
   :result nil
   :files {1 "(+ 82 34)" 2 "bar" 3 "biz"}})
