clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
athomasoriginal 2021-04-27T00:04:28.464800Z

I just start with vanilla interop

(-> (js/promise ...)
    (.then handle-success)
    (.catch handle-error))
If the logic is too complex I would opt for <p! macro. 90% of the time I don’t need anything more though.

athomasoriginal 2021-04-27T00:09:36.468700Z

> but what’s idiomatic? Either of the 3 options is fine. For me, I opt for minimal to keep the bundle small and the code “simple”.

gorjusborg 2021-04-27T01:49:16.469Z

nice, thanks

2021-04-27T09:35:16.469800Z

Is anyone familiar with sci ? I'm trying to start using it in cljs and I'm surprised by how metadata behaves and I wonder what I'm doing wrong.

borkdude 2021-04-27T09:35:42.470100Z

@pmooser I'm relatively familiar with it. There is also a #sci channel

1😳2😁
paulbutcher 2021-04-27T14:03:33.474Z

I suspect I’m missing something pretty obvious here: can someone help me spot what? I’m getting a warning in my production build from this line (using ocall from binaryage/oops ):

cljs.core/>, all arguments must be numbers, got [#{js/clj-nil clj-nil} number] instead

  43                 (> (ocall js/Math :abs z) 10))
                     ^---
I expected that I should be able to fix it by adding a type hint like this:
(> ^number (ocall js/Math :abs z) 10)
But I still get the same warning when I do so. What am I missing? Thanks!

p-himik 2021-04-27T14:30:03.474100Z

I think that's because ocall is a macro. You don't need ocall here at all: (> (.abs js/Math z) 10). Maybe add ^number there, if it complains again.

paulbutcher 2021-04-27T14:46:47.474400Z

I guess having started to use ocall for some of my JS interop, I’ve got used to using it for all of it… I’d still love to understand why the type hint doesn’t work in the code that does use ocall?

p-himik 2021-04-27T15:34:22.474600Z

Metadata tags are reader tags. I think what's going on is that that metadata ends up being applied to the (ocall ...) form, but then that form is expanded into some other form because ocall is a macro, and macroexpansion process does not retain metadata.

p-himik 2021-04-27T15:36:29.474800Z

Seems related: https://clojure.atlassian.net/browse/CLJ-865

paulbutcher 2021-04-27T16:41:23.475Z

Ah! That makes sense. Thanks 👍

2021-04-27T20:22:19.480200Z

I just posted a real stumper in #re-frame, but the more generic CLJS part of my problem is that lein cljsbuild once seems to be copying a file into resources/js/out/... that is not the file as it exists in the dependency I’m require-ing. I’ve done lein clean, I’ve deleted resources/public/js/out, I’ve even tried deleting ~/.cljs/.aot_cache/*, and I still get a crippled version of the file. What’s really weird is that this started happening after upgrading from a really old version of re-frame-10x to the latest version, however checking the git history of the file in question shows that the crippled version has never been checked in (and *I* certainly am not removing the code that I need to compile it!). So where is this crippled version coming from? Is there some other cache somewhere I can purge?

2021-04-27T20:42:25.482300Z

Alternate version of the question: lein cljsbuild once is copying day8.reagent.impl.component from somewhere, but the file it’s copying is very clearly not the version of the file that exists (or ever has existed) in the repository, so where else could it be coming from?

thheller 2021-04-27T20:47:15.483500Z

@manutter51 run lein repl then (require '<http://clojure.java.io|clojure.java.io>) and (<http://clojure.java.io/resource|clojure.java.io/resource> "day8/reagent/impl/component.cljs") (or maybe cljc). that will tell you where exactly that file is from

2021-04-27T20:50:09.483900Z

ok, let me give that a shot

2021-04-27T20:52:06.484600Z

Oho! ~/.m2/repository/re-frisk/re-frisk/1.5.0/re-frisk-1.5.0.jar!/day8/reagent/impl/component.cljs Now that’s something I’d have spent a long time sleuthing out! Thanks a ton!