This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-30
Channels
- # aleph (4)
- # announcements (5)
- # architecture (1)
- # aws (5)
- # babashka (12)
- # beginners (143)
- # chlorine-clover (4)
- # cider (16)
- # clj-kondo (44)
- # cljfx (26)
- # cljsrn (2)
- # clojure (34)
- # clojure-europe (28)
- # clojure-gamedev (1)
- # clojure-nl (3)
- # clojure-provo (2)
- # clojure-spec (6)
- # clojure-uk (17)
- # clojurescript (99)
- # code-reviews (6)
- # core-async (15)
- # cryogen (9)
- # cursive (14)
- # data-science (1)
- # datomic (16)
- # duct (1)
- # events (4)
- # exercism (1)
- # figwheel-main (3)
- # fulcro (3)
- # hugsql (7)
- # leiningen (4)
- # malli (15)
- # off-topic (13)
- # pathom (8)
- # re-frame (7)
- # reitit (35)
- # remote-jobs (1)
- # sci (10)
- # shadow-cljs (32)
- # sql (5)
- # tools-deps (102)
- # tree-sitter (3)
- # uncomplicate (7)
- # vim (40)
- # xtdb (8)
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
@U4P4NREBY 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)))
Now everytime the route is hit, whatever code that was eval’ed in the REPL will get executed
@U9E8C7QRJ 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…?@U4P4NREBY 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
Ah, I see. So #'tech.matterindustries.titan.ion.api-gateway.service-handler/routes
is just a regular var that you’re deref’ing?
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.
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?
Set an environment variable / system property when starting REPL, have top-level expression wrapped in (if my-env-var-is-set...)?
I should have said reload any namespace instead of a namespace