clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
witek 2021-03-30T10:07:15.369200Z

Hello. Why does case behave this way?

(case :foo 
  :foo "foo") => "foo"

(let [foo :foo]
  (case :foo 
    foo "foo")) => nil
I would expect both to yield "foo". What am I missing here?

flowthing 2021-03-30T10:09:47.370Z

The test constants in case must be compile-time literals.

thheller 2021-03-30T10:10:06.370300Z

https://clojuredocs.org/clojure.core/case "The test-constants are not evaluated."

witek 2021-03-30T10:12:36.370500Z

Thank you. So what is the idiomatic way to do a "case" like conditional when having the values as constants?

flowthing 2021-03-30T10:14:44.370700Z

(let [foo :foo]
  (condp = :foo 
    foo "foo"))
Provided that I understand your question correctly.

flowthing 2021-03-30T10:15:45.370900Z

Well, that's probably not exactly what you're after, but (condp = ...) is pretty common.

witek 2021-03-30T10:31:28.371100Z

I can live with that. 😉 Thank you!

metehan 2021-03-30T17:55:54.373700Z

hi I am planning to make a simple flat-file blog which are the options for server side cljs development

metehan 2021-03-30T17:58:35.373800Z

to be more clear I am looking simple framework with basic routing

athomasoriginal 2021-03-30T18:33:04.374Z

I would happily nominate Reitit + Ring-Jetty.

athomasoriginal 2021-03-30T18:34:02.374200Z

You may already know this, but “frameworks” are not much of a thing in Clojure. At least when compared to what is available in JS land.

fsd 2021-03-30T19:04:08.377600Z

Hello There, I am working with react-map-gl and trying to disable the + - for map zoom in and out but cannot get the button selected (let [zoom-in-button (first (-> js/document (.getElementsByClassName "mapboxgl-ctrl-zoom-in")))]) when shadow-cljs page load and this return HTMLCollection [] and I get this error Uncaught TypeError: Cannot read property ‘setAttribute’ of null. I am not sure why I can’t get the button selected.

metehan 2021-03-30T22:46:04.378300Z

thank you I am going to check it now

metehan 2021-03-30T22:50:20.378500Z

this is exactly what I was looking for 🙂

👍 1
2021-03-30T23:23:15.380900Z

Can I force the Clojurescript compiler to output Javascript that uses export for each function that should be exported instead of module.export ?

tvirolai 2021-03-31T11:44:02.392800Z

You can do this using Shadow-CLJS, check out this thread: https://clojureverse.org/t/generating-es-modules-browser-deno/6116

2021-03-31T15:47:55.395900Z

OK. Thanks