Fork me on GitHub
#clojurescript
<
2021-03-30
>
witek10:03:15

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?

flowthing10:03:47

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

witek10:03:36

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

flowthing10:03:44

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

flowthing10:03:45

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

witek10:03:28

I can live with that. 😉 Thank you!

thheller10:03:06

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

metehan17:03:54

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

metehan17:03:35

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

athomasoriginal18:03:04

I would happily nominate Reitit + Ring-Jetty.

athomasoriginal18:03:02

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.

metehan22:03:04

thank you I am going to check it now

metehan22:03:20

this is exactly what I was looking for 🙂

👍 3
fsd19:03:08

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.

hkjels23:03:15

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

tvirolai11:03:02

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

hkjels15:03:55

OK. Thanks