cljs.repl.browser/handle-post
multimethod | since v0.0-927 | Edit |
(handle-post m _ _)
(defmulti handle-post (fn [m _ _ ] (:type m)))
(defmethod handle-post :ready [_ conn _]
(send-via es ordering (fn [_] {:expecting nil :fns {}}))
(locking server/lock
(.clear server/connq))
(send-for-eval conn
(binding [ana/*cljs-warnings*
(assoc ana/*cljs-warnings*
:undeclared-var false)]
(cljsc/-compile
'[(set! *print-fn* clojure.browser.repl/repl-print)
(set! *print-err-fn* clojure.browser.repl/repl-print)
(set! *print-newline* true)
(when (pos? (count clojure.browser.repl/print-queue))
(clojure.browser.repl/flush-print-queue!
@clojure.browser.repl/xpc-connection))] {}))
identity))
(defmethod handle-post :print [{:keys [repl content order]} conn _]
(constrain-order order
(fn []
(binding [*out* (or (and repl (.get outs repl)) *out*)]
(print (read-string content))
(.flush *out*))))
(server/send-and-close conn 200 "ignore__"))
(defmethod handle-post :result [{:keys [content order]} conn _]
(constrain-order order
(fn []
(return-value content)
(server/set-connection conn))))