clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
macrobartfast 2021-04-16T02:17:46.201400Z

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?

macrobartfast 2021-04-16T07:28:13.210100Z

shadow-cljs inspector… get outta town… one sec…

macrobartfast 2021-04-16T07:30:00.210300Z

well I’ll be damned.

macrobartfast 2021-04-16T07:31:28.210500Z

I’ve seen that in a framework… I just didn’t realized I had it with any shadow-cljs project.

💯 1
macrobartfast 2021-04-16T07:33:01.210700Z

reading about what you mean by tap> here https://clojureverse.org/t/introducing-shadow-cljs-inspect/5012

Franco Gasperino 2021-04-16T17:02:38.213600Z

Glad i read this thread. The tap & inspect functionality is a great find

💯 1
macrobartfast 2021-04-17T00:40:08.215400Z

any thoughts on starting an app with lein new luminus someapp +reagent +shadow-cljs vs create-cljs-app?

macrobartfast 2021-04-17T00:41:01.215600Z

it sounds like you might do neither.

djblue 2021-04-17T02:16:27.218Z

Sorry, I haven't used those templates but I do really enjoy reagent 💯

djblue 2021-04-17T02:19:28.218700Z

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

djblue 2021-04-17T02:21:14.218900Z

(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 compatibility

macrobartfast 2021-04-17T03:11:27.220700Z

what does that enable (I forgot the advantages of React hooks).

djblue 2021-04-17T03:47:52.220900Z

I think it mostly just makes it easier to interop with various libraries in the react ecosystem

macrobartfast 2021-04-16T02:18:39.202100Z

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.

macrobartfast 2021-04-16T02:20:31.203Z

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.

macrobartfast 2021-04-16T02:21:18.203900Z

I’m not against a combined front-end/back-end situation, btw… I just recall loooong restarts when I bork my recur experimentation. 🙂

macrobartfast 2021-04-16T02:21:33.204300Z

Maybe some approaches reload quickly or work that out another way.

djblue 2021-04-16T05:49:38.206300Z

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 👌

djblue 2021-04-16T05:50:57.206500Z

I think you can also setup shadow-cljs to proxy API requests to another server if you are really sold on two separate processes

djblue 2021-04-16T05:52:29.206700Z

Is cider interrupt not able to kill this repl eval?

djblue 2021-04-16T05:55:44.206900Z

https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http lists a variety of ways you could configure the dev server

macrobartfast 2021-04-16T06:13:37.207100Z

It doesn’t seem to work… the page gets hung in an endless reload… but I’m probably doing something wrong.

macrobartfast 2021-04-16T06:15:09.207300Z

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.

macrobartfast 2021-04-16T06:15:27.207500Z

How do you create your shadow-cljs apps at the start?

macrobartfast 2021-04-16T06:15:45.207700Z

I fell in love with create-shadow-cljs-app.

💯 1
macrobartfast 2021-04-16T06:15:58.207900Z

but can easily move on to whatever.

macrobartfast 2021-04-16T06:17:23.208100Z

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.

macrobartfast 2021-04-16T06:18:11.208300Z

Reading the link you had in your message earlier now.

macrobartfast 2021-04-16T06:19:48.208500Z

Holy smokes… it looks like I can do it all in shadow-cljs with a ring handler. I think you just said that, haha. 🙂

💯 1
macrobartfast 2021-04-16T06:20:29.208700Z

Demerits to me for not RTFM.

😆 1
djblue 2021-04-16T06:29:51.209Z

I usually just copy a shadow-cljs.edn from project to project 😬

djblue 2021-04-16T06:37:08.209400Z

Another benefit with having both in the same process is you can use the shadow-cljs inspector for both clj/cljs

djblue 2021-04-16T06:41:55.209600Z

You can access it via http://localhost:9630/ just in case you didn't know 👌

djblue 2021-04-16T06:43:05.209800Z

Being able to tap> clojure data into a dedicated ui is a game changer :clojure-spin:

2021-04-16T15:46:52.212500Z

I wonder is there any documentation on the type hint ^js here: (.registerComponent ^js (.-AppRegistry rn) “app” #(reagent/reactify-component views/root))

2021-04-16T15:49:04.213100Z

https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs this section Type-hint to help externs generation explains it

2021-04-16T16:13:14.213200Z

Isn’t that something owned by the cljs compiler and not shadow?

p-himik 2021-04-16T16:59:48.213400Z

It is. But it's documented in more than one place.

2021-04-16T17:33:51.213900Z

Is it documented on the clojurescript site? I didn't see it there

p-himik 2021-04-16T17:35:31.214100Z

Stuff like ^js/SomeType is documented. I haven't seen the documentation for ^js specifically there, but it's in the CLJS compiler code.