Fork me on GitHub

Ya, the whole thing involves proper trade offs. I think the idea of live view is to treat web UIs like online games do. But the truth is that all it is doing is starting from the other side, and in both situation where you want to end up is somewhere in the middle


Most online game have quite a few tech in the client as well allowing the illusion of smoothness until sync happens


But the truth of LiveView is that its just trying to build a Elixir only full stack. And since it can't compile to JS, they tried taking a full server side approach


Slightly tangential, but I read recently in the first comment here that Bloomberg terminals do all rendering server side with spidermonkey and send the results back to the (non web) client


Should a Clojure backend send data as edn to a Clojurescript or JSONify it and then js->clj over it at the other end? If I do send it as edn, is it simply an edn/read-string operation on the frontend?

Alex Miller (Clojure team)05:12:59

Transit is designed for this purpose

Alex Miller (Clojure team)05:12:20

It’s faster and smaller than edn or json


A cursive question. Is there a quick way to get to the end of the line? cmd -> is mapped to move around to next form. Annoying as hell


Home for start of line End for end of line?


@srijayanth What prevents you from unmapping the shortcut in the settings?


@U2FRKM4TW - that’s what I am ending up having to do, now I have to come up with other shortcuts for navigating through the forms. I am on a mac but without a mac keyboard


Seems like a good opportunity to pitch IdeaVim. :D


Function key and right arrow, not code 🙂


How do I start my own server using leiningen in a figwheel project? I am trying to use a lein exec. I have a script called server.clj. Pretty much like but with leiningen instead of CLI


Classpath errors. Doesn’t find ring on the classpath


It finds ring, doesn’t find the jetty adapter. Upon reading, it looks like the ring jetty adapter is a separate dependency. Fixed.


I’ve run lein do exec -p scripts/server.clj, fig where fig is an alias


my jetty port also has :join? set to false


While the scripts/server starts, it doesn’t look like the alias executes


From what I can see, for some vague reason the scripts/server doesn’t finish executing, so lein doesn’t execute fig. However, the scripts server needs to connect to an instance of figwheel, websocket times out.


Any ideas anyone? The goal is simply to launch a custom server and figwheel with lein

Duck Nebuchadnezzar15:12:09

I'm in a similar boat as you, not having a single script to launch both. I typically launch my server and then in another terminal start figwheel, or I have emacs start figwheel when I connect.


Does it work if you use deps and clojure cli?

Duck Nebuchadnezzar15:12:52

I'm doing it using lein figwheel, so I don't know


lein figwheel? Or just lein with figwheel main? Lein figwheel is a different plugin


Any figwheel experts?


@srijayanth almost seems like you may have more of a lein question. But also it isn’t clear what the script is doing and also what the alias fig is doing.


@mikerod - sorry. The script simply starts a ring jetty server. The fig alias simply launches figwheel.


Hang on while I paste some


(require '[ring.adapter.jetty :refer [run-jetty]])
(require '[ring.middleware.defaults :refer [wrap-defaults site-defaults]])
(require '[ring.util.response :refer [resource-response content-type]])

(defn handler [req]
  (let [_ (println "the request is " req)]
      (when (= "/" (:uri req))
        (some-> (resource-response "index.html" {:root "public"})
                (content-type "text/html; charset=utf-8")))
      {:status  404
       :headers {"Content-Type" "text/html"}
       :body    "Not found"})))

  (wrap-defaults handler site-defaults)
  {:port 4000
   :join? false})
(println "Started server")


@srijayanth well it wouldn’t make sense for this to work I think. Lein is going to launch separate JVM processes for each of these. The run jetty script should terminate after it completes. Which would end the jetty process as well. Then the fig starting would be a separate process and unrelated at that point.


Yeah. Figured that lein do is sequential anyway. I am going to do this programmatically instead of with lein


I think for what you are trying it needs to be done fully in one process - so yes programmatically.


Not sure I have a clear understanding of what you are doing still. But it’s common to use your own server with figwheel.


I do it al the time with lein-figwheel but it should have a similar method with figwheel.main


You should be able to just start a regular clj and then a fig cljs repl. And use your own server for serving your pages. Figwheel will use its for its code reloading web socket and cljs repl after that.


To do similar with lein, you could put the script stuff instead in an repl init config. Or just call it via repl once started


Thanks @mikerod - I am doing exactly what it is you are talking about. which is to have a single lein task that launches both the server and figwheel. The documentation figwheel provides on this specific point is only for CLI and not for lein. Do you have a handy repo by any chance that I can look at?


Haven’t been able to make example easily since only been answering from phone. Are you using cider?


cider-jack-in-cljs for example sets up a cmd to run like:

(do (require 'figwheel.main) (figwheel.main/start <options here>))


so that’s how you start it programmatically, which you could do any time after starting your server


to have lein do that automatically, just have to build it into some sort of init script lein will run for the process


the clojure CLI example just uses the -i flag, which is the same idea there I believe


so you call your fn in your script to start your server in something like I believe


If you are starting with something like cider and launch 2 repl - one for clj and one “sibling” for cljs then you’d probably need to make this :init operation be able to only create the server if not already created (aka “idempotent”) . To avoid making multiple or attempting to when new repls are opened.


That’s the script/server.clj


the alias is simply

:aliases {"fig" ["trampoline" "run" "-m" "figwheel.main"]


I know why it doesn’t work and I also figured out that the only real way to do this is to programmatically call figwheel


programmatically launch the server and then figwheel


Is it possible to use --watch and --repl together with cljs.main? Edit: actually now m issue seems to be that the windows cljs.jar isn't recognizing my git deps in deps.edn. Using clj from CLI with cljs.main seems to work with -r and -w but not together