Fork me on GitHub
#joyride
<
2022-05-29
>
pez07:05:25

NB: the evaluateCode() function now has moved to repl.evaluateCode(). (Though for now it is also available in its old place as well.) See updated API docs: https://calva.io/api/

pez09:05:31

I've added an example utility library for the Calva API here: https://github.com/BetterThanTomorrow/joyride/tree/master/examples/.joyride/scripts/z_joylib Including it as a text snippet here as well.

borkdude12:05:36

I'm currently in the woods. Will check tonight :-)

borkdude15:05:40

Reacted. You're close :)

mauricio.szabo19:05:13

@U0ETXRFEW I think i got it, commented on Github my solution 🙂

borkdude19:05:49

Yep, I think @U3Y18N0UC nailed it

pez19:05:00

I got the refer working, very similar to your solution, @U3Y18N0UC. Mixed and match a bit from nbb and the example.

borkdude20:05:53

@U0ETXRFEW I don't think you need apply here:

(apply gobject/getValueByKeys exports path)

borkdude20:05:20

But you need to pass an array in that case. For this you can use:

(.split module-name ".")

pez20:05:23

Isn't that what I am doing?

borkdude20:05:44

No, you are using str/split which returns a vector

pez20:05:17

So getValuesByKeys takes an array?

pez20:05:01

Cool. I'll try it. Then we should fix that where I picked this apply up as well, probably. 😃

borkdude20:05:06

apply also works, but my performance OCD was being triggered

borkdude20:05:31

(getValueByKeys obj (.split "foo" "."))

borkdude20:05:56

or (apply getValueByKeys obj (str/split "foo" ".")) both work

borkdude20:05:11

but the first one isn't converting things to and from js <> cljs

borkdude20:05:36

Yeah, I should change that :) In more recent code I discovered the array thing ;)

pez20:05:38

I also fixed a potential overwrite when requires might refer to something named the same as the module/namespace.

borkdude20:05:55

Oh interesting. Can you name an example of that?

pez20:05:07

Let's see...

pez20:05:29

Contrived:

["betterthantomorrow.calva" :as calva-ns :refer [v0]]
            ["betterthantomorrow.calva$v0" :as calva-js :refer [v0 repl ranges]]

pez20:05:45

clj-kondo seems to be picking it up somehow...

borkdude20:05:40

@U0ETXRFEW So what is the problem with the above? Yes, you get refer conflicts, but that is expected?

borkdude20:05:33

["betterthantomorrow.calva$v0" :as calva-js :refer [v0 repl ranges]]
The v0 in refer here is unexpected, since you already went into the v0 property with $v0

borkdude20:05:15

You should probably write that as:

["betterthantomorrow.calva$v0" :as v0 :refer [repl ranges]]

pez20:05:48

Yes, it was contrived. What I mean is that something I refer from a module might be named the same as the module. (I might have a function named v0 in the v0 export.)