       ["emacsclient" "-n" (str "+" file-line) file-name] ;; we are emacs aware
       [open-file-command file-name file-line])))
 
-(defn handle-client-msg [server-state data]
+(defn handle-client-msg [{:keys [browser-callbacks] :as server-state} data]
   (when data
     (let [msg (read-msg data)]
-      (when-let [command (and (= "file-selected" (:figwheel-event msg))
-                              (get-open-file-command server-state msg))]
-        (try
-          (.exec (Runtime/getRuntime) (into-array String command))
-          (catch Exception e
-            (println "Figwheel: there was a problem running the open file command - " command))
-          )))))
+      (if (= "callback" (:figwheel-event msg))
+        (when-let [cb (get @browser-callbacks (:callback-name msg))]
+          (cb (:content msg)))
+        (when-let [command (and (= "file-selected" (:figwheel-event msg))
+                                (get-open-file-command server-state msg))]
+          (try
+            (.exec (Runtime/getRuntime) (into-array String command))
+            (catch Exception e
+              (println "Figwheel: there was a problem running the open file command - " command))))))))
 
 (defn add-build-id [{:keys [build-id]} msg]
   (if build-id

                                        :output-dir output-dir
                                        :file-md5-atom (atom {})})
    :file-change-atom (atom (list))
    :open-file-command open-file-command
   })


                       { :msg-name msg-name 
                         :project-id (:unique-id opts)})))

(defn setup-file-change-sender [{:keys [file-change-atom compile-wait-time connection-count] :as server-state}
                                wschannel]
  (let [watch-key (keyword (gensym "message-watch-"))]
    (swap! connection-count inc)
    (add-watch file-change-atom
               watch-key
               (fn [_ _ o n]
