bhauman / lein-figwheel

Figwheel builds your ClojureScript code and hot loads it into the browser as you are coding!
Eclipse Public License 1.0
2.88k stars 210 forks source link

Managing multiple connections in REPL #690

Closed chbrown closed 6 years ago

chbrown commented 6 years ago

Scenario: I've got multiple tabs open to different pages of my app, and Figwheel starts new sessions with each of them, changing the REPL prompt to:

dev:cljs.user!{:conn 3}=>

Now it seems that when I eval something at the Figwheel REPL, it evals it in the first session (the active session before I opened additional tabs). (Or maybe it's the newest one? It seems to have an opinion, but I can't infer what logic it's following. I thought maybe it was following the latest active tab, but that doesn't seem to explain it either.)

So my questions are:

  1. How do I switch to a specific connection? I figure they're numbered/identified in the order they were started, like with screen or tmux.
  2. How can I determine what connection I'm currently talking to?

This might be just a request for documentation; I dug around in the source code a little but didn't find any relevant functions. I suspect there's some (switch-to-conn id) function that I missed, in which case maybe it should be documented in the "Figwheel Controls:" listing that prints out when figwheel starts?

I'm using latest figwheel + sidecar; project.clj snippet:

  :plugins [... [lein-figwheel "0.5.16"]]
  :profiles {:dev {:dependencies [[figwheel-sidecar "0.5.16"] ...] ...} ...}

FWIW, Figwheel is what convinced me to give ClojureScript a shot (coming from plain Clojure), so thanks! :)

bhauman commented 6 years ago

The evaluation goes to all Connected environments, and the first result retuned is displayed.

In order to get isolation one simply needs to close the other tabs.

This is something that has has worked in practice for quite some time.

That being said the next iteration of figwheel (figwheel-main) only evaluates in one environment, and allows you to choose which one.

The interesting thing about this type of development, is how quickly one can create and remove connected environments by opening, closing and refreshing tabs. Thus making it a rapid way of managing connections compared to explicitly choosing them in the REPL itself.

On May 18, 2018, at 1:13 PM, Christopher Brown notifications@github.com wrote:

Scenario: I've got multiple tabs open to different pages of my app, and Figwheel starts new sessions with each of them, changing the REPL prompt to:

dev:cljs.user!{:conn 3}=> Now it seems that when I eval something at the Figwheel REPL, it evals it in the first session (the active session before I opened additional tabs). (Or maybe it's the newest one? It seems to have an opinion, but I can't infer what logic it's following. I thought maybe it was following the latest active tab, but that doesn't seem to explain it either.)

So my questions are:

How do I switch to a specific connection? I figure they're numbered/identified in the order they were started, like with screen or tmux. How can I determine what connection I'm currently talking to? This might be just a request for documentation; I dug around in the source code a little but didn't find any relevant functions. I suspect there's some (switch-to-conn id) function that I missed, in which case maybe it should be documented in the "Figwheel Controls:" listing that prints out when figwheel starts?

I'm using latest figwheel + sidecar; project.clj snippet:

:plugins [... [lein-figwheel "0.5.16"]] :profiles {:dev {:dependencies [[figwheel-sidecar "0.5.16"] ...] ...} ...} FWIW, Figwheel is what convinced me to give ClojureScript a shot (coming from plain Clojure), so thanks! :)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.