cursive

Issues at: https://git.io/cursive-issues
simongray 2020-10-30T09:07:16.169Z

Is there a way to bind a key combo to send a piece of code to the REPL? I am developing a pedestal web service and it’s becoming a bit tiresome to navigate to the Rich comment block where my (restart-server) call is every time I make some changes… :S

✅ 1
danieroux 2020-11-02T10:47:37.174400Z

@simongray interceptors is the service-map in your start The important line that you need in your service map while developing, would be (assoc ::http/routes route-fn) . That route-fn dynamically expands the routes on every call - so point it to your routes

simongray 2020-11-02T11:00:39.174600Z

Ah, I see. So #'tech.matterindustries.titan.ion.api-gateway.service-handler/routes is just a regular var that you’re deref’ing?

danieroux 2020-11-02T11:08:51.174800Z

Yes, the app routing table

simongray 2020-11-02T11:19:54.175Z

Ok. Thanks! I think I'm just not familiar with the syntax here. Never deref'ed a var before. Anyway, I guess it wouldn't work without the deref since yo made it this way. I'm just not sure why.

cfleming 2020-10-30T09:12:43.169100Z

Yep: https://cursive-ide.com/userguide/repl.html#repl-commands

🎶 1
simongray 2020-10-30T09:19:08.169400Z

Awesomesauce!

simongray 2020-10-30T09:28:29.169700Z

Thank you very much! Works perfect.

danieroux 2020-10-30T11:08:32.169900Z

@simongray it should not be necessary to call (restart-server) in pedestal. This is our dev-server:

(defn- route-fn
  "Use the deref of the namespace to get hot-reloaded namespaces."
  []
  (route/expand-routes
    (deref #'tech.matterindustries.titan.ion.api-gateway.service-handler/routes)))

(def interceptors
  (-> service-handler/service
    ; Get ion provider out of there
    (dissoc ::http/chain-provider)
    ; hot-reloaded-fn ftw!
    (assoc ::http/routes route-fn)
    (merge
      {::http/type  :jetty
       ::http/port  7001
       ::http/join? false})
    (http/default-interceptors)
    (http/dev-interceptors)))

danieroux 2020-10-30T11:11:01.170200Z

Now everytime the route is hit, whatever code that was eval’ed in the REPL will get executed

roklenarcic 2020-10-30T12:22:37.171100Z

I don’t know if this would be a cursive feature or nrepl feature, but how could I specify a snippet of code I want to run every time I reload a namespace while connected to REPL?

simongray 2020-10-30T14:34:41.171200Z

@danie Interesting. Can you explain a little how it works? I am currently working with something like

(defn start []
  (http/start (http/create-server service-map)))
but I don’t see any servers started in your snippet so I’m unsure what to do with it…?

Jakub Holý 2020-10-30T20:50:38.171500Z

Set an environment variable / system property when starting REPL, have top-level expression wrapped in (if my-env-var-is-set...)?