 
 ;; TODO fix figwheel-core to use this
 (defn ^:export after-reloads [f]
-  ;; TODO simplify and verify it works
-  (swap! reload-promise-chain #(.then % (fn [_] (Promise. (fn [r _] (f) (r true)))))))
+  (swap! reload-promise-chain #(.then % (fn [_] (Promise. f)))))
 
 ;; --------------------------------------------------------------
 ;; Websocket REPL

;; http async polling - long polling
;; ------------------------------------------------------------------

;; TODO explore shorter long polling timeouts
;; TODO make long polling client reconnect when server isn't present
;; TODO perhaps different endpoint for long polling?

;; TODO probably better to base the simple polling on a similar pattern

;; agents would be easier but heavier and agent clean up is harder
(defn long-poll-send [comm-atom msg]
  (let [data (volatile! nil)

                       (assoc comm :respond respond)))
    (when @has-messages (long-poll-send comm-atom nil))))

;; TODO this is an abstract part of sending a message and getting a
;; response
(defn ping [conn]
  (let [prom (promise)
