0

I followed along the following instructions for my own project: https://github.com/cemerick/austin/tree/master/browser-connected-repl-sample. I think things derailed at step 2:

Once you're in the REPL (it will start up in the sample app's main namespace, cemerick.austin.bcrepl-sample), evaluate (run). That just starts jetty on port 8080; if you open a browser to that server, you'll see this page (which the sample re-uses as its only content).

I've been starting my server with $ lein ring server-headless as opposed to starting in the REPL and I'm pretty sure that's what's causing [:script (cemerick.austin.repls/browser-connected-repl-js)] to not generate the proper javascript. In the browser, the source code shows <script></script> while it gets properly generated in the REPL.

How would I run the equivalent of $ lein ring server-headless from the REPL if this is indeed the problem?

deadghost
  • 5,017
  • 3
  • 34
  • 46

2 Answers2

0

I dealt with a similar situation a time ago.

Here I left the steps I followed to obtain this austin script:

  1. Introduce in the project repl: (def repl-env (reset! cemerick.austin.repls/browser-repl-env (cemerick.austin/repl-env)))
  2. adapt the result expression Browser-REPL ready @ http://localhost:XXXXX/ZZZ/repl/start to the js script: <script>;goog.require('clojure.browser.repl');clojure.browser.repl.connect.call(null, 'http://localhost:XXXX/ZZZ/repl');</script>. Note that only 'XXXX/ZZZ' changes each time
  3. write into nrepl (cemerick.austin.repls/cljs-repl repl-env)
  4. reload your browser

Good luck!

tangrammer
  • 3,041
  • 17
  • 24
0

I never got it working with $ lein ring server-headless since I switched to immutant before I found much need to figure this out.

Immutant creates a repl when it starts whose port can be specified in your project file. I use cider in emacs and connect to it with M-x cider and specify the port when prompted. From here just follow the tutorial steps. One thing that caught me and took a few minutes to figure out was that the script tag in your html with browser-connected-repl-js needs to be in the very end of your <body>; doesn't seem to work in <head>.

The key take-away for set-ups with similar issues is that you need to reset an atom and the javascript in your html code needs access to this atom. For the original problem with $ lein ring server-headless, you'll probably want to start the server in the repl and follow the tutorial.

deadghost
  • 5,017
  • 3
  • 34
  • 46