Fork me on GitHub
#clojurescript
<
2022-04-25
>
p-himik10:04:00

If you prefer to stay as close to React as possible, then there's https://github.com/lilactown/helix If you prefer to have a higher level abstraction, then there's https://github.com/reagent-project/reagent Don't know about the former as I don't use it, but the latter has a lot of examples that cover pretty much 100% of all use cases, including using stateful React libraries like tldraw.

🙏 1
Stef Coetzee10:04:24

Thank you @U2FRKM4TW! This is super helpful.

👍 1
dfornika16:04:47

Does anyone know of a way to embed compiled cljs directly into an html file? I'm looking for a way to create a single-file html report that could be viewed offline. Is it possible to do this with figwheel-main?

p-himik16:04:59

Just your regular <script> tag. Not sure about figwheel-main but you can do it with some CLJ script that uses e.g. Selmer or some Hiccup library.

dfornika17:04:10

Hmmm ok, thanks. I was hoping there might be some tooling to automate the process or something. I might have to do a bit of experimentation. I wonder if I just take the .js file that figwheel-main spits out and paste it into a <script> tag, if that will work.

p-himik17:04:59

That should work. Because that's pretty much what <script> with a URL does, except that the browser loads that URL first.

dfornika17:04:49

Right, ok. I'm a bit surprised this doesn't seem to be a common use-case but maybe I'm using the wrong search terms or looking in the wrong places.

dfornika17:04:25

Thanks for the suggestions

p-himik17:04:08

Sharing static HTML files with embedded JS is not a common use-case by itself. :)

lread17:04:25

Probably not what you are looking for but there is also https://github.com/babashka/scittle.

hairfire20:04:44

cljs on node.js noob question: Does anyone know of an example that TCP connects at ip-address/port, writes a string, reads all available data for a specified period of time, disconnects, and prints all of the data that was read?

dgb2320:04:38

The net module in the Nodejs std lib can do this. Would be a good example to get used to JS interop :)

hairfire20:04:19

I'm really struggling (e.g., Days of research) to understand how to write a node.js application. I've been doing Clojure/JVM for years with core.async, but I can't seem to get anything to work on CLJS/Node. My main program just terminates, and nothing runs the way I expect it to. I believe I'm missing some, hopefully simple, concept, and/or bit of code, that will lead me to an Ah Ha moment. Any thoughts?

dgb2320:04:22

Ok the way I would approach this would be to first write (copy from an example/tutorial) the Nodejs code. And then I would try to translate it step by step with CLJS interop. That’s how I learned CLJS interop, comming from JS.

1
dgb2320:04:12

get rid of any abstractions like async and just do the dumb 1:1 thing

👍 1
hairfire20:04:14

Thanks, I'll check it out

dgb2320:04:51

There is also often a listen / run or similar method on Nodejs that you have to call in order to actually await on messages.

dgb2320:04:25

And this is really useful as a cheat sheet for JS interop: https://lwhorton.github.io/2018/10/20/clojurescript-interop-with-javascript.html

✔️ 1