This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-02-24
Channels
- # babashka (6)
- # beginners (11)
- # calva (4)
- # clojure (12)
- # clojure-madison (2)
- # clojure-norway (25)
- # clojure-spec (8)
- # clojure-sweden (1)
- # clojurescript (17)
- # datalevin (1)
- # datomic (8)
- # events (5)
- # ghostwheel (1)
- # hyperfiddle (16)
- # off-topic (16)
- # pedestal (1)
- # reagent (6)
- # reitit (1)
- # releases (3)
- # scittle (1)
- # shadow-cljs (5)
- # specter (2)
- # squint (4)
Hi! In a regular ClojureScript project I have just spent some time rewriting a piece of code to work on a JS object instead of Clojure clojure data. The reason is that I need to set the result on a JS object from a library I am using. Basically what I had was:
• cljs-ajax:clj-data -> transform -> clj->js
-> set-on-js-library-object
And now I have:
• cljs-ajax:raw-js -> transform -> set-on-js-library-object
The payload is pretty big so the clj->js
step took too much time. I leveraged applied-science/js-interop for this and the new transform code is not too horrible, but still… I need to be really careful not to miss a #js
tag somewhere, or forget to do into-array
on some result from a map
or filter
or whatever. I.e. There is a bit too much code there that does not deal with the business problem I am trying to solve.
Now to my question. 😃 Has anyone leveraged squint
for this kind of task? (Please let me know if “this kind of task” is unclear.) I’m thinking that the transform code would stay pretty close to the original one I had, and be less error prone expressed in squint CLJS.
js-interop has a macro for this called js
I believe
not sure how well it works, since it's marked experimental, but may be worth a try
https://github.com/applied-science/js-interop/pull/32