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/
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.
I need some help here, @borkdude ! 😃 https://github.com/BetterThanTomorrow/joyride/pull/72
I'm currently in the woods. Will check tonight :-)
Reacted. You're close :)
@pez I think i got it, commented on Github my solution 🙂
Yep, I think @mauricio.szabo nailed it
I got the refer working, very similar to your solution, @mauricio.szabo. Mixed and match a bit from nbb and the example.
Super!
@pez I don't think you need apply here:
(apply gobject/getValueByKeys exports path)But you need to pass an array in that case. For this you can use:
(.split module-name ".")Isn't that what I am doing?
No, you are using str/split which returns a vector
So getValuesByKeys takes an array?
yeah
Cool. I'll try it. Then we should fix that where I picked this apply up as well, probably. 😃
apply also works, but my performance OCD was being triggered
(getValueByKeys obj (.split "foo" "."))or (apply getValueByKeys obj (str/split "foo" ".")) both work
but the first one isn't converting things to and from js <> cljs
Your OCD should have triggered when you wrote this: https://github.com/BetterThanTomorrow/joyride/blob/0db51d7298ef68536dd7157424a3ec19c02053a9/src/joyride/repl_utils.cljs#L48 😃
Yeah, I should change that :) In more recent code I discovered the array thing ;)
I also fixed a potential overwrite when requires might refer to something named the same as the module/namespace.
Oh interesting. Can you name an example of that?
Let's see...
Contrived:
["betterthantomorrow.calva" :as calva-ns :refer [v0]]
["betterthantomorrow.calva$v0" :as calva-js :refer [v0 repl ranges]]brb
clj-kondo seems to be picking it up somehow...
@pez So what is the problem with the above? Yes, you get refer conflicts, but that is expected?
["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 $v0You should probably write that as:
["betterthantomorrow.calva$v0" :as v0 :refer [repl ranges]]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.)
Ah right