Fork me on GitHub

I know there must be a way to do this simply, but can't think of it


(def values ([1 2] [3 4] [5 6]))


What I'd like to get back is ([1 3 5] [2 4 5])


Does anyone have an idea what the incantation might be?


(map vector values)


* (apply map vector values) since it uses the multiple-coll arity of map

✔️ 8

hi, I'm having trouble connecting cider to shadow-cljs' nrepl. in theory I should be able to cider-connect and then just eval my expressions right there, right? assuming it has to do something to do with this error, but spacemacs says I have the newest version of cider apparently


@shin which cider-nrepl version do you have in shadow-cljs.edn? or project.clj/deps.edn depending on what you use?


@thheller updated it to the beta mentioned in the error now, still doesn't seem to work though


and what is the error now?


@thheller says I need nrepl 0.4.4 or newer, but I can't nrepl in any dependencies


just add [nrepl "0.6.0"]?


and remove tools.nrepl in case you have that


I don't know enough about cider so I can't help any further


alright, thank you anyway 🙂 cljs is not so fun without a repl though


I know that many people use cider with shadow-cljs so it should work. no clue how current this is but maybe it helps?


will check it out!


Are there any Electron Project Template for Clojurescript ?


They are not updated. Also, I think they are abondened.


I would still give them a try. I think Electron development in Clojure is generally declining though. If I were building a desktop app in Clojure I’d look at cljfx (


What about sharing a business-logic and UI with your web and mobile ?


I would try either descjop or lucmartens/cljs-electron and see if they do the job.


Thank you, sir. 😇


@shin hi the current doc of how to use cider with shadow-cljs is outdated. since there's a built-in support. You can use C-c M-j launch a cljs repl. cider will ask you to select a repl type. then you just select shadow, the all things works.


@thheller I want to update the cider section of shadow-cljs document, if there's no maintainer. using cider with shadow is much easier now.


I noticed that my browser closes the shadow-cljs connection after a few seconds at work, could that be part of my problem?


you mean few seconds?


yeah, a little error pops up telling me the connection to shadow was closed


is the connection ever succeed?


that is a websocket connection, you can check in browser console.


I can load the page and do stuff, it just doesn't update on changes, but maybe the connection never worked: WebSocket connection to '<ws://xxx:9630/ws/worker/app/c0ce03b9-eebd-4c4b-988d-e96f3029881e/dc640c5b-3250-4969-946f-a0e5f9f4a472/browser>' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT


shadow-cljs by default tries to connect to the same host the original page was loaded from


which target are you using?


if you run behind a proxy or on a different host you might need


so that would be why the repl doesn't work either?

Daw-Ran Liou16:08:24

Hi, I found a case where :advanced compilation results in “TypeError: l.C is not a function,” which is similar to what [this link]( describes. In my case, I.C() is compiled from a javascript interop form (.val snapshot). I can provide more details if needed. Is .val shadowing any cljs.core function like the link suggests? Eventually I got around the issue by calling the .toJSON method to get around it.


@dawranliou is snapshot an external JS object?


aka .val should be valid even after advanced optimizations


then you should notate it as such: (.val ^js snapshot)


that will prevent optimizations from turning the .val into some single-letter method

Daw-Ran Liou16:08:54

I definitely missed the ^js notation. Thanks.

Daw-Ran Liou16:08:39

Is it generally a good idea to put ^js everywhere I want to call a method on a js object?


you should try turning on infer-externs first and seeing if you get any warnings


and you generally only need to hint once inside fn bodies


externs should be inferred from usage


if for some reason it doesn't work then file a bug in JIRA

Daw-Ran Liou16:08:25

Ok let me try everything one at a time. Thanks @lilactown @dnolen!

Daw-Ran Liou16:08:00

I’m using shadow-cljs and once I started using {:infer-externs :auto} I saw the warnings. Adding ^js does solve the problem, so no bugs there. 🙂

👍 8

our webapp has <script src=cdn/Chart.js> and uses this in cljs as js/Chart. However doo with chrome-headless lacks this script when it runs our test so we cannot include test files that require our usage of charts. Does anyone know off hand how to modify the page that chrome headless will eventually load?


solution: :doo {:karma {:config {"customContextFile" "resources/chrome-headless-testrunner.html"}}} and copying and modifying the custom context file that karma uses:


anyone here familiar with react native in cljs and pagination?


@dmateja724 there's also a React Native channel #cljsrn if you don't get a response here


@dnolen thanks :thumbsup:


I'm trying to understand how cljs.js/load-analysis-cache! behaves (or is supposed to behave) in a couple different scenarios. Originally I was using a trick/technique described by (I'm pretty sure) @mfikes . It uses a macro: (defmacro analyzer-state [[_ ns-sym]] '~(get-in @env/compiler [:cljs.analyzer/namespaces ns-sym]))` and then defines a state var (def state (cljs.js/empty-state)) and then it is used, for example, by (cljs.js/load-analysis-cache! state 'aerial.hanami.core (analyzer-state 'aerial.hanami.core))


That works fine, but can take a fair amount of time in various cases. So, looking around it seemed that if the actual pre-generated cache, in this case the core.cljs.cache.json file content, is passed to load-analysis-cache! it would just take the already computed result and use it. But it seems to behave in the same way as using the 'analyzer-state' macro. Am I totally in the weeds on this??


@jsa-aerial What are you trying to understand? (It isn’t clear to me what question you have.)


Take the content of a cache file, feed it to read-string and then pass it to load-analysis-cache!, is it supposed to be used as is to update the compiler state?


When I do this, it seems to recompute the compiler analysis from the name space that's passed and not use the cache content passed


Put another way, it takes as much time passing the precomputed and saved cache content as when giving it the 'analyzer-state' variation


These three variations seem to behave in exactly the same way: The analysis is run from scratch


@jsa-aerial In both cases, data is loaded into an atom. So the question becomes: How fast can you load data into a map? When using a macro to dump a literal map into your generated code, this will have roughly the same perf as if you read Transit-encoded data to obtain that map.


Well, this is more than loading into a map - I mean it takes 20 seconds or so


It sounds like you are saying your loaded cache is not being used


It certainly seems that way, yes.


It is very strange - you can pass nil (or indeed, not pass any 3rd arg) and the results are the same


I’m AFK, but take a look at the logic surrounding the *loaded-libs* var in cljs.js


The other thing is - once it is done, things just work as expected. You can eval-str stuff that uses things from the ns, you can define new funcs in the ns and use them, etc. etc


There’s really no magic here. Loading the analysis cache is just that—it is not the same as requiring a namespace and loading JS, etc


Looking at the source for load-analysis-cache! it is indeed a simple swap. But when I run this interactively (at repl via figwheel) it does indeed seem like it is loading the namespace along with all its requires. Maybe this is some odd/toxic interaction with figwheel?


Are you loading the analysis cache for a given namespace, followed by requiring that namespace?


the reverse - namespaces are required and only then are the analysis caches loaded.


If you want to optimize the situation where you require pre-compiled namespaces, then your *load-fn* implementation can call back with the JavaScript and analysis cache.


If you do that, then cljs.js calls load-analysis-cache! with the the analysis cache you supply:


Yeah, I was looking into the *load-fn* usage scenario. When /where should this be bound? I know eval-str opts can take it, but is there a 'global' scenario?


If you have a static load function, you could conceivably just set! it


I'm becoming pretty convinced that the weird behavior I see has something to do with some interaction between figwheel, piggyback, and /or cljs-repl


(You can use it as an optimization in certain situations when you know other stuff is already loaded and you just need the analysis cache to additionally be loaded.)


That's exactly what I want - the optimization situation


Looking at the source for load-analysis-cache! it is indeed a simple swap. But when I run this interactively (at repl via figwheel) it does indeed seem like it is loading the namespace along with all its requires. Maybe this is some odd/toxic interaction with figwheel?