Fork me on GitHub

If you prefer to stay as close to React as possible, then there's If you prefer to have a higher level abstraction, then there's 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

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?


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.


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.


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


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.


Thanks for the suggestions


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


Probably not what you are looking for but there is also


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?


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


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?


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.


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

👍 1

Thanks, I'll check it out


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


And this is really useful as a cheat sheet for JS interop:

✔️ 1