Fork me on GitHub

According to, cljs.spec and cljs.test are ports of their respective clojure namespaces.


But I’ve got some cljs tests that require the clojure namspaces (not the cljs namespaces) and everything seems to run just fine.


Is there a reason to prefer requiring cljs.spec and cljs.test in cljs tests or does it not really matter?


IMO it doesn’t really matter and I slightly prefer using clojure.*


but someone might disagree with me


since so many libs relied on clojure.core clojure.test etc., they implemented special handling of it in the compiler to rewrite clojure.* to cljs.*

Mario C.02:02:03

When using Cljsbuild with whitespace optimization this worked fine (.-addr (.-dataset e) where addr is a custom attribute. Then when setting optimization to advanced, I am getting nil. Any idea whats going on?

Mario C.02:02:54

For some odd reason I had to do (aget target-el "dataset" "addr")


If you're using shadow-cljs, you should be able to write (.-addr ^js (.-dataset ^js e)).


you should avoid property based access for data


goog.object/get is preferred, avoid aget - only for arrays

Alex Miller (Clojure team)02:02:23

you need a faq page to just point to that @dnolen :) (like


@mario.cordova.862 under advanced compilation property access will get renamed - that's why it doesn't work and should be avoided - (unless it's JS language properties or mature standard browser APIs)

👍 4

@david_clojurians we auto-alias -> - it helps with portability (i.e. cljc files) - it's intentional so feel free to use that feature as you see fit


@posobin you can trivially await promises w/ core.async - there's a patch to add support to core.async directly that I need to review once more


when the promise succeeds you can write that a core.async channel


core.async go blocks support async/await style syntax via the blocking operators <! >! etc.

Gleb Posobin15:02:47

But this way it is harder to deal with exceptions, no?


core.async has try/catch support just like async/await


but sure I expect the debug support for async/await to be pretty good since there's native support


IME though if you keep it simple, core.async is fine


is there a way to preprocess some files before compilation like converting svgs to hiccup components?


Yes, write a macro that reads a file, transforms SVG string into hiccup and expands into a component definition


yeah but that would require clojure primitives right like read a file


What's wrong with that?


hmm i am missing something here - the GCC won’t complain having a clojure primitive inside a clojure script file?


Macros are written in clj files, then when called in cljs files they are running at compile time. So you can read a file and transform contents at compile time and return hiccup which will be then compiled to js. I'd recommend to read more about macros in Clojure and ClojureScript.


yeah agreed thanks


Yeah macros in ClojureScript are awesome. You have access to the entire Clojure ecosystem and the file system so you can go crazy :)


Has anyone had any luck getting a react async select to work in cljs? the callback/promise on loadOptions is throwin me off


I suppose the root of the issue is- anyone have any tips for interop that requires a promise / callback? Do I use a go block?


Callbacks and promises work in CLJS the same as JS


Why can’t you use promise?


Perhaps I'm confused at a lower level of understanding. I'll look into using a promise directly


@shanelester55 Here's a script which uses promises directly: Maybe the example is useful to you.


Ahh thank you!


Boy, this is perplexing. I got an error is not a function, stack trace indicates that it was happening in clj->js. Ok, I’ve got some values that I’m passing to clj->js, I’ll pprint them and see what the problem is. Now I’ve got is not a function in pprint. Ok, printing doesn’t work, I wonder what the types are for those values? So I try (doseq [v values] (pprint {:type (type v)})). Now I’ve got is not a function in Object.cljs$core$accumulating_seq_count.


What the heck have I got in my data that’s making everything blow up like that??


(Apparently that last one may be happening in a call to seq or count. Or both.)


@manutter51 do you have a lazy seq in that data? that'll make things look weird sometimes


Ah, yes, I do, thanks for the clue, that wouldn’t have occurred to me


Oh word, I accidentally had the arguments to remove in the wrong order. What a wild way for that bug to show up!


Tks much @thheller I’d have been all afternoon on this one. 😉

Oliver George22:02:08

I'm looking for a good reference for how to evaluate CJLS expressions in the browser. Goal being allowing users to define functions (like defining a formula in an excel spreadsheet).


that’s probably not very good reference for a beginner, but you can hopefully google more articles about self-hosting clojurescript compiler in your app


ah, sorry, now looking at the link you posted below and it is about self-hosted compiler, so you already found it 🙂


If you want a real example of this that is quite self contained, have a look at Saite Specifically the analyzer.clj and compiler.cljs under the src/cljs/aerial/saite dir.


Also, the codemirror.cljs shows how this is used interactively. If you want to see it all in action, grab the uberjar and just start hacking!

Oliver George02:02:53

Thanks. Seems like i should consider an interpreter too. looks interesting.

👍 4

I use sci in a number of projects. It's really great!

Oliver George22:02:26

I found this article dated 2015. Is it a good approach or have things moved on?