clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
Chris K 2020-09-18T01:12:32.001800Z

I'm trying to use compojure, and clojurescript for building websites (also planning to use hiccup), but I don't know how I can use them alltogether. I know that for hiccup, I can do (include-js "file") stuff, but not sure how it will work out for clojurescript. Anyone know any good resources for linking these softwares? thanks

hoppy 2020-09-18T03:40:47.004900Z

hi, working on a nodejs cljs project, that uses npm serialport. If I build this as a standalone .js with shadow-cljs, then the serial port reacts to incoming data as expected. In the repl, however, I can see data come in (via some led's) but I never get notifications of this. I'm guessing it's some odd event-loop stuff, but this is above my node pay grade. Is there something that can be done in code run in the repl to let this stuff flow?

alpox 2020-09-18T07:28:01.007200Z

@hoppy are you expecting log entries in the repl? I remember shadow-cljs had some trouble showing nodejs logs in the repl a while ago

hoppy 2020-09-18T10:27:56.008900Z

@alpox, guess I was expecting to see a println inside an '.on("data"')' Hadn't considered that that might not actually work - hmm

hoppy 2020-09-18T10:41:21.009900Z

@alpox - you nailed it. the code is running, just not printing (in this particular case). atoms are my friend - Thank you!

hairfire 2020-09-18T14:54:49.014100Z

Anyone know how to do this: document.getElementById("main-div").clientWidth in cljs?

2020-09-19T16:08:28.035200Z

My preference:

(-> js/document (.getElem..) (.-clientWidth))

hairfire 2020-09-22T15:04:49.079700Z

Just got back to this. Thanks!

2020-09-18T14:56:06.015100Z

(.-clientWidth (.getElementById js/document "main-div"))
should do the trick

dpsutton 2020-09-18T14:57:15.015400Z

alternatively, (.. js/document (getElementById "app") -clientWidth)

👍 3
p-himik 2020-09-18T19:03:53.025300Z

js-keys

2020-09-18T19:04:07.025600Z

Thanks @p-himik

p-himik 2020-09-18T19:04:27.026100Z

It's better to just answer your own question than to remove it some time after you posted it. :)