3

I'm developing my first full-stack Clojure application. I've managed to get the following working properly in Linux Mint:

  • leiningen
  • figwheel + garden[auto] = Interactive SPA development with hot code and CSS reloading
  • leiningen REPL for Server with rebel-readline, start server at REPL, and serve SPA to browser
  • leiningen uberjar compiles, jar file runs, and SPA is served by server

What I can't figure out how to do is get a development environment set up that allows me to have a server REPL and an SPA REPL at the same time so that I can integrate sente for websocket support and monitor the re-frame app-db state within the SPA REPL. I suppose, ideally, I'd like to have figwheel + gargen[auto] running with the SPA communicating with the server via the sente websocket.

2 Answers2

0

My response is not really what you asked for, but it might interest you nonetheless I believe so bear with me.

Did you try the lightmod editor? It aims to be a fullstack editor with minimal setup. In fact, when you launch it you can preselect template for your project, and get automatically a REPL for backend, and a REPL for your SPA, with auto-reloading etc. It does not have all of Emacs goodies but I found it really good to get a quick setup.

Julien Rousé
  • 1,115
  • 1
  • 15
  • 30
  • 1
    I have tried LightMod. It does exactly what I'm trying to do. I downloaded it from github, studied its source code, and I have not been able to figure out how it provides both the server and client REPLs at the same time. – user2592857 Jan 29 '19 at 19:27
  • Tried to read it as well, but it's way beyond what I can handle in Clojure right now. Maybe message Zach Oakes to ask him directly? – Julien Rousé Jan 29 '19 at 20:04
0

It turns out that the sente function used within the ClojureScript app, named make-channel-socket!, called to initiate the connection back to the sente-websocket-server running on the app's server has a third parameter, options map, key named :host. By default, sente sets the :host value to the server from where the ClojureScript app was loaded.

If one runs 'lein figwheel' and loads the ClojureScript app via the figwheel server, sente, by default, trys to connect to the figwheel server, which is NOT, of course, running a sente websocket server.

For development mode, one must: 1. Start the app server in a terminal (e.g., 'lein repl') 2. Compile the ClojureScript app with a :host value of 'localhost:' 3. Run the ClojureScript app via figwheel in another terminal 4. Connect to the figwheel server from the browser (e.g., 'localhost:3449')

When the ClojureScript app is loaded into the browser via the figwheel server it executes the sente connection call that now makes a connection to the sente websocket server running in the app server.

This is FANTASTIC! Now one can use figwheel, with its REPL for the browser, and run the app server, with its REPL, at the same time.