Fork me on GitHub
#clojurescript
<
2021-08-17
>
Pepijn de Vos11:08:06

Is this something that makes sense to rewrite as a transducer?

(defn find-overlapping [sch]
  (->> sch
       (mapcat (fn [[k v]] (map #(vector k %) (offset-wires v))))
       (reduce (fn [coords [name val]]
                 (update coords val conj name)) {})
       vals
       (filter #(> (count %) 1))))
I figured you can replace ->> with comp but there is no reduce that returns a transducer, so then it becomes kind of a nasty process where you turn the mapcat into a transducer, the reduce into a transduce, and then the vals+filter step into another one and collect that with into/sequence or something like that?

p-himik12:08:32

FWIW you could rewrite it using group-by instead of reduce. Should make it a bit more clear.

emccue13:08:53

also there are tons of libraries out there which provide a map-values

pesterhazy15:08:45

Howdy, is anyone using Jest with Clojurescript? I'm particularly interested in experience with writing component tests using React Testing Library

CW23:08:39

I am also interested in this but have no news to share

pesterhazy05:08:55

We are thinking of working on integration of Jest with cljs and possibly open sourcing it but wanted to check if there's prior work

ccann16:08:02

can anyone help me understand the difference between using CLJS to generate a static site versus a static-site generator like Jekyll, Hugo, etc.? Specifically the output. Are there ramifications to a JS output versus just HTML? I’m new to the SSG game (and trying to build a blog for me and my friends!)

ccann16:08:48

I’d like to write Clojure or ClojureScript, using Hiccup and a CSS framework like Bulma or Tailwind, to generate static assets I can host on a CDN

p-himik16:08:39

If you ship JS code (one that's supposedly not used when you generate just HTML), the amount of data your readers will have to download will be larger. Unless you have large generated HTML documents that require only a little bit of code to generate. Apart from that, some rather rare Internet users simply disable JS in their web browsers. If all you require can be expressed with nothing but HTML+CSS, I would definitely go that road.

ccann16:08:24

So is it feasible to write Clojure(Script) to generate HTML+CSS only?

ccann16:08:01

I saw some tools, Cryogen and Static, which might be that sort of thing?

p-himik16:08:44

I have never dealt with SSG, but CLJ[S] is a general-purpose language, so sure. :) Yeah, I've heard of Cryogen before, seems like the right tool for the job. Haven't heard about Static.

p-himik16:08:59

Do you have a link to Static? Kinda hard to find with that name.

athomasoriginal17:08:27

The question is framed in an odd way. You can generate a static site with any language you choose. If you are using CLJS to just generate HTML which is then served by a server, you would have just created your own SSG (Hugo et al) but in CLJS.

athomasoriginal17:08:59

Are you looking to create an SSG tool or do you want to use CLJS with a SSG tool?

ccann17:08:57

Neither actually, I want to create a site that I can host on a CDN or Github Pages or similar and I want to do it in either Clojure or ClojureScript. I was trying to ask about the difference between generating a bunch of HTML with an SSG versus building a conventional cljs frontend. Is it primarily SEO and artifact size? Since one has a bunch of javascript and the other doesn’t Let me know if that doesn’t make any sense because I’m new to this kind of thing

athomasoriginal18:08:03

No worries. The answer to this question would be the same as with vanilla JS. So yes, if your site is a SPA then bundle, seo etc can be factors.

athomasoriginal18:08:53

What kind of site are you building?

ccann21:08:46

Essentially a blog

ccann21:08:57

After a bit of research I think I understand the differences now. Though the hybrid approaches like Gatsby.js are pretty confusing!

athomasoriginal13:08:39

100%. They don’t make it easy to see what they’re doing 😛 . If it helps at all, I just redid my blog. I used Eleventy and haven’t found a need to use JS/CLJS to enhance the blog yet. Often times there isn’t much need to flood simple sites with JS (and by extension, CLJS). CLJS is what I would add to a simple site (like a blog or marketing site) if I was just trying to learn it, or started getting to a point where I need to manage a bit of state and i’m already adding more JS libraries than it’s worth. If it’s a SPA, or Behaviour intensive site, I would opt for CLJS most times. Only other consideration is do I need to hand the site off to another developer/client without ability to find CLJS developers.

ccann03:08:59

awesome, it does help, and I too was / am gravitating towards 11ty. I think I may go the route of generating HTML via hiccup though, just because I love Hiccup and why learn another templating language when I already know this one?

athomasoriginal11:08:49

TMK you can add hiccup and edn to eleventy because they have a flexible templating/data processing hook in