Selaa lähdekoodia

enhance: get worker runtime id automatically

Tienson Qin 1 vuosi sitten
vanhempi
sitoutus
b4757dad0e
1 muutettua tiedostoa jossa 10 lisäystä ja 3 poistoa
  1. 10 3
      src/dev-cljs/shadow/user.clj

+ 10 - 3
src/dev-cljs/shadow/user.clj

@@ -13,6 +13,13 @@
 
 ;; Get the runtime id from http://localhost:9630/runtimes, pick the one which shows `browser-worker`
 (defn worker-repl
-  [runtime-id]
-  (assert runtime-id "runtime-id shouldn't be empty")
-  (api/repl :app {:runtime-id runtime-id}))
+  ([]
+   (when-let [runtime-id (->> (api/repl-runtimes :app)
+                              (filter (fn [runtime] (= :browser-worker (:host runtime))))
+                              first
+                              :client-id)]
+     (prn :worker-runtime-id runtime-id)
+     (worker-repl runtime-id)))
+  ([runtime-id]
+   (assert runtime-id "runtime-id shouldn't be empty")
+   (api/repl :app {:runtime-id runtime-id})))