Create websocket connection optionally
`scittle.nrepl` should only create a ws port optionally if `SCITTLE_NREPL_WEBSOCKET_PORT` is set.
This commit is contained in:
parent
20e125dd6c
commit
4b778ef3f9
2 changed files with 2 additions and 3 deletions
|
|
@ -5,8 +5,7 @@
|
||||||
:tasks {http-server {:doc "Starts http server for serving static files"
|
:tasks {http-server {:doc "Starts http server for serving static files"
|
||||||
:requires ([babashka.http-server :as http])
|
:requires ([babashka.http-server :as http])
|
||||||
:task (do (http/serve {:port 1341 :dir "."})
|
:task (do (http/serve {:port 1341 :dir "."})
|
||||||
(println "Serving static assets at http://localhost:1341")
|
(println "Serving static assets at http://localhost:1341"))}
|
||||||
(deref (promise)))}
|
|
||||||
|
|
||||||
browser-nrepl {:doc "Start browser nREPL"
|
browser-nrepl {:doc "Start browser nREPL"
|
||||||
:requires ([sci.nrepl.browser-server :as bp])
|
:requires ([sci.nrepl.browser-server :as bp])
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
(defn ws-url [host port path]
|
(defn ws-url [host port path]
|
||||||
(str "ws://" host ":" port "/" path))
|
(str "ws://" host ":" port "/" path))
|
||||||
|
|
||||||
(let [ws-port (or (.-SCITTLE_NREPL_WEBSOCKET_PORT js/window) 1340)]
|
(when-let [ws-port (.-SCITTLE_NREPL_WEBSOCKET_PORT js/window)]
|
||||||
(set! (.-ws_nrepl js/window)
|
(set! (.-ws_nrepl js/window)
|
||||||
(new js/WebSocket (ws-url "localhost" ws-port "_nrepl"))))
|
(new js/WebSocket (ws-url "localhost" ws-port "_nrepl"))))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue