This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-03
Channels
- # announcements (21)
- # aws (6)
- # babashka (28)
- # beginners (39)
- # biff (1)
- # calva (23)
- # cider (5)
- # clj-kondo (108)
- # clojure (11)
- # clojure-europe (17)
- # clojure-nl (2)
- # clojure-nlp (10)
- # clojure-uk (8)
- # clojurescript (29)
- # community-development (4)
- # conjure (20)
- # css (3)
- # datalevin (9)
- # datomic (3)
- # events (2)
- # figwheel-main (11)
- # fulcro (36)
- # honeysql (7)
- # humbleui (5)
- # interceptors (4)
- # introduce-yourself (3)
- # jobs (1)
- # lsp (51)
- # malli (1)
- # meander (71)
- # minecraft (8)
- # other-languages (18)
- # pathom (15)
- # polylith (25)
- # portal (10)
- # re-frame (5)
- # reitit (15)
- # releases (1)
- # remote-jobs (1)
- # shadow-cljs (11)
- # tools-deps (27)
A lot of stuff in browser produces a promise of a chan. How do you test these functions in unit test? I cannot blockingly take from a chan or something?
There are async tests: https://clojurescript.org/tools/testing#async-testing
How would I use something like https://www.npmjs.com/package/@react-midi/hooks in reagent?
I started with this import ["@react-midi/hooks" :as midi-hooks]
but I'm unsure on how to call the useMIDI()
function in a way that doesn't cause an error.
Step 1: Make sure that what you imported is what you expect to see and not undefined
or something else
Step 2: Consult https://github.com/reagent-project/reagent/blob/master/doc/ReactFeatures.md#hooks
Awesome, this works:
(defn example []
(let [aaa (midi-hooks/useMIDI)]
[:div
(js/console.log aaa)]))
(defn home-page []
[:div
[:f> example]])
Thank you as always!Ever wondered the “best” way to interop with javascript? Should you use “dot special form” or goog.object
? Do you need to type hint when using dot notation? how does this relate to Advanced Compilation? Well turns out, there IS a correct answer to all of these questions! and you can find out why during tomorrow’s episode of http://www.theclouncil.com where we will be covering some clojurescript intricacies that you won’t want to miss! Join the channel #the-clouncil for the zoom link!

I have wondered this! and it is not documented afaik so I wrote up some stuff here: https://widdindustries.com/clojurescript-jsinterop/
and tl;dr my preferred interop style is the dot
style (foo.bar.baz)
but unfortunately that won't survive advanced compilation (open issue https://clojure.atlassian.net/browse/CLJS-3315)
will be interesting to see what the clouncil has to say on this
A similar question was asked a few months ago. I want to embed some data, perhaps 1 or 2 MB, in an HTML page that is a basis for an SPA. What is the best? Meta with a content value with an EDN or transit+JSON string? Or perhaps a script tag? Or a data tag? Are there some limits or significant performance implications with either approach?
I'd go with a <script>
tag with application/transit+json
.
Not EDN because it would be larger and slower to parse it.
Why can I write both:
(js/console.log "hey")
(.log js/console "hey")
and
(.send um-one-output [0x91, 60, 0x7f])
but not
(um-one-output.send [0x91, 60, 0x7f])
(the latter examples have some objects defined by me, but I suspect is the same for all user defined objects?)seems to work fine
(def x #js{"my_fn" (fn [a] (.log js/console "HI" a))})
(x.my-fn 200)
IIRC the last example breaks on optimized builds, something to do with externs inference.
And it works properly with js/*
stuff because that stuff already has externs.
I myself don't use a.b
syntax at all unless it also has js/
in front of it. And even then, it's pretty much only js/console
stuff that I sprinkle around during development.
Thanks guys, where is the fact that I can write js/console.log
documented? I hope to find the caveats there
Here: http://cljs.github.io/api/syntax/dot But it's rather base-bones in this regard. I think there's an issue about the externs issue that I described.
if you want to dive in, you can trace the calls from here:
https://github.com/clojure/clojurescript/blob/40358fc4c53090676da82e3f4c52920003678902/src/main/clojure/cljs/analyzer.cljc#L3549
If i'm following correctly the analyzer will output a map with :op :host-call
which is emitted here: https://github.com/clojure/clojurescript/blob/40358fc4c53090676da82e3f4c52920003678902/src/main/clojure/cljs/compiler.cljc#L1432
that analysis fn analyze-dot
has some externs checks so maybe that's where the bug is that Eugene mentioned?
interop stuff doesnt have much official doc afaik. I wrote this https://widdindustries.com/clojurescript-jsinterop/ which mentions issue: https://clojure.atlassian.net/browse/CLJS-3315
thanks @U051V5LLP I added a comment to that issue with your info.
it's something I'd like to see addressed and may look at fixing it myself at some point
oh nice! thanks @U051B9FU1 Might drop in and ask Mike if he knows : )
Hi all! So I'm currently working on a project that pulls sass, clj and cljs assets from the java classpath via a dependnecy jar. Specifically, the sass was being compiled via sass4clj/jsass/libass, but those are now deprecated, and jsass throws errors on an M1 mac. Seems like it's time to move on. Dart-sass is now the reference impl for sass, but I haven't seen a lot of examples on how to use it as part of a cljs build. Anyone have an pointers or resources? Ideally I'd like to be able to pull resources from a jar and compile them via the dart sass compiler.
> I haven't seen a lot of examples on how to use it as part of a cljs build
Just use it as a separate tool.
I ended up writing a CLJ script that I run with shadow-cljs run
that shells out to sass
.
That gives you flexibility where you can pull anything from anywhere since it's all driven by CLJ code.
You could also call sass
from Shadow: https://shadow-cljs.github.io/docs/UsersGuide.html#_calling_watch_via_clj_run
Something like
(let [cmd ["npx" "sass" "--watch" "-I" "../foobar/src/scss" "-I" "."
"src/scss/:target/dev/public/css/"]
process (-> (ProcessBuilder. ^"[Ljava.lang.String;" (into-array String cmd))
(.inheritIO))]
(.start process))
But in this example sass
process isn't killed if java process is killed, though it stops on ctrl-c. I have better version somewhere.Doesn't help with requiring resources from classpath though. I've just copied the few lines of css I might have from some clj libs into the project. Mostly just using deps from npm.
@U2FRKM4TW, @U061V0GG2, thanks very much, I am already using shadow in our build, so the approach you two recommend looks very promising. The shelling out was the missing piece, I think. I should be able to filter the classpath for sass resources/directories, and launch any watch tasks from there.
Here is a full Shadow watch with Dart Sass example: https://gist.github.com/Deraen/695c94848d3ee05990239d403f7fe733