I need to add a back end to what I’ve created with create-shadow-cljs-app which has been awesome… I’ve used Luminus and so on in the past but am not attached to anything… I develop locally and will be hosting it all on something like Digital Ocean… I’ve gotten wary of the totally integrated front-and-back end solutions as any hang makes me have to reload it all. Is it possible to develop the front and back ends separately and still connect to the repl’s from Emacs? I always run into CORS confusion doing that while developing locally… any thoughts or quick suggestions of approaches to look at?
shadow-cljs inspector… get outta town… one sec…
well I’ll be damned.
I’ve seen that in a framework… I just didn’t realized I had it with any shadow-cljs project.
reading about what you mean by tap> here https://clojureverse.org/t/introducing-shadow-cljs-inspect/5012
Glad i read this thread. The tap & inspect functionality is a great find
any thoughts on starting an app with lein new luminus someapp +reagent +shadow-cljs
vs create-cljs-app
?
it sounds like you might do neither.
Sorry, I haven't used those templates but I do really enjoy reagent 💯
They recently added https://github.com/reagent-project/reagent/blob/master/doc/ReactFeatures.md#function-components in the 1.0 release which makes it super easy to leverage react hooks
(def functional-compiler (reagent.core/create-compiler {:function-components true}))
(reagent.dom/render [my-app] div functional-compiler)
It's opt in though to preserve backwards compatibilitywhat does that enable (I forgot the advantages of React hooks).
I think it mostly just makes it easier to interop with various libraries in the react ecosystem
I’m also excited about a couple frameworks but they still don’t play nicely with my Emacs live dev setup so I’m still going this route for now.
I often use cider-connect-to-clj&cljs in Emacs when a framework type thing launches both… but I guess if I did them separately I’d do them in turn.
I’m not against a combined front-end/back-end situation, btw… I just recall loooong restarts when I bork my recur experimentation. 🙂
Maybe some approaches reload quickly or work that out another way.
My preferred approach is running a shadow-cljs dev server with a custom ring handler for my API. Single nrepl connection for both clj/cljs repl, single http server so no CORS and it starts up fast enough 👌
I think you can also setup shadow-cljs to proxy API requests to another server if you are really sold on two separate processes
Is cider interrupt not able to kill this repl eval?
https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http lists a variety of ways you could configure the dev server
It doesn’t seem to work… the page gets hung in an endless reload… but I’m probably doing something wrong.
Cool… this is helpful. I’m not sold on any approach at all… I just am pretty confused probably about what’s actually going on.
How do you create your shadow-cljs apps at the start?
I fell in love with create-shadow-cljs-app.
but can easily move on to whatever.
My probably incorrect thinking is that I have to add a ton of stuff in to shadow-cljs to get a back end working along with it… when the truth may not be that at all.
Reading the link you had in your message earlier now.
Holy smokes… it looks like I can do it all in shadow-cljs with a ring handler. I think you just said that, haha. 🙂
Demerits to me for not RTFM.
I usually just copy a shadow-cljs.edn from project to project 😬
Another benefit with having both in the same process is you can use the shadow-cljs inspector for both clj/cljs
You can access it via http://localhost:9630/ just in case you didn't know 👌
Being able to tap>
clojure data into a dedicated ui is a game changer :clojure-spin:
I wonder is there any documentation on the type hint ^js here: (.registerComponent ^js (.-AppRegistry rn) “app” #(reagent/reactify-component views/root))
https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs this section Type-hint to help externs generation explains it
Isn’t that something owned by the cljs compiler and not shadow?
It is. But it's documented in more than one place.
Is it documented on the clojurescript site? I didn't see it there
Stuff like ^js/SomeType
is documented. I haven't seen the documentation for ^js
specifically there, but it's in the CLJS compiler code.