This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-06
Channels
- # announcements (3)
- # beginners (83)
- # calva (11)
- # cider (24)
- # cljdoc (2)
- # cljs-dev (1)
- # clojure (216)
- # clojure-berlin (1)
- # clojure-dev (18)
- # clojure-europe (8)
- # clojure-italy (5)
- # clojure-losangeles (2)
- # clojure-nl (4)
- # clojure-spec (34)
- # clojure-uk (75)
- # clojuredesign-podcast (12)
- # clojurescript (33)
- # clojutre (13)
- # community-development (1)
- # core-async (38)
- # cursive (19)
- # datomic (28)
- # duct (3)
- # emacs (1)
- # events (5)
- # figwheel-main (3)
- # fulcro (93)
- # kaocha (20)
- # lambdaisland (2)
- # off-topic (40)
- # pathom (17)
- # pedestal (8)
- # quil (1)
- # re-frame (14)
- # reitit (19)
- # shadow-cljs (34)
- # sql (8)
- # tools-deps (6)
- # vim (1)
- # xtdb (8)
- # yada (18)
I need to access externs.js file (for a cljsjs package) from Clojure. What’s the best way of doing that
Have any of the ideas from atomic-layout been ported to clojure? Or does anyone have any thought or opinions on it? I'm just starting to look into it and i'm not sure i get the picture just yet.
@ag If you know the name of the file in the JAR, you could use io/resource
to access it, like this:
$ clj -Sdeps '{:deps {cljsjs/react {:mvn/version "16.9.0-0"}}}'
Clojure 1.10.1
user=> (require '[ :as io])
nil
user=> (slurp (io/resource "cljsjs/react/common/react.ext.js"))
You could even get at the name of the externs file like this
user=> (:externs (read-string (slurp (io/resource "deps.cljs"))))
["cljsjs/react/common/react.ext.js"]
That is exactly what I needed. Once again, you saved my day. And I have failed to properly explain what my problem is in #clojure, so I didn’t get right answers immediately.
Are the performance characteristics for :extend-via-metadata
protocols different than for regular protocols?
if true, then you have 3 options - direct invocation, always tried first, no difference in perf
metadata extension second, external extension third
b/c #2 is checked, #3 is slower
or rather, all the answers above are for Clojure. I assume similar for cljs, but could be wrong.
Thanks! Im not sure I fully understand what you’re referring to with “external extension” though? extend-type
?
not sure how much upside there would be at this point
a large runtime, including gc, would be required
also, clojure being hosted, there’s not really anything on the host side in wasm
Ok, something super weird is going on with some data I have. I'm in a CLJS REPL:
x
=>
[{[:metric/id #uuid"0a9640da-13a0-49b6-9e82-87b38ac2619f"] [{(:metric/dashboard-series
{:window [#inst"2019-09-06T16:20:32.277-00:00"
#inst"2019-09-06T19:20:32.277-00:00"]}) [:dashboard-series/name
:dashboard-series/points]}]}]
y
=>
[{[:metric/id #uuid"0a9640da-13a0-49b6-9e82-87b38ac2619f"] [{(:metric/dashboard-series
{:window [#inst"2019-09-06T16:20:32.277Z"
#inst"2019-09-06T19:20:32.277Z"]}) [:dashboard-series/name
:dashboard-series/points]}]}]
(= x y)
=> false
Those two data structures are identical... but apparently they aren't? I'm almost 100% certain it has to do with the list.(= (get (first x) [:metric/id #uuid"0a9640da-13a0-49b6-9e82-87b38ac2619f"])
(get (first y) [:metric/id #uuid"0a9640da-13a0-49b6-9e82-87b38ac2619f"]))
=> false
I don't think so. This arose because I couldn't write some transit:
(cognitect.transit/write
(cognitect.transit/writer :json)
y)
Error: Cannot write
x
was defined like this:
(def x '[{[:metric/id #uuid"0a9640da-13a0-49b6-9e82-87b38ac2619f"] [{(:metric/dashboard-series
{:window [#inst"2019-09-06T16:20:32.277Z"
#inst"2019-09-06T19:20:32.277Z"]}) [:dashboard-series/name
:dashboard-series/points]}]}])
y
was defined by pulling some data off something generated at runtime.If I dig way into that structure, it is actually a List
(type (first (keys (first (get (first y) [:metric/id #uuid"0a9640da-13a0-49b6-9e82-87b38ac2619f"])))))
=> cljs.core/List
But the macro isn't doing anything strange. It's just pulling the value out and putting it in another place. Either way, the two values look fine.
Well that was fun... Turns out it was the dates! The dates were generated from cljs-time haha
Out of curiosity, was the issue that two different types of object were being printed as #inst <something>
, so they looked textually the same when printed, but were not =
to each other in Clojure because of the different types?