This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-03
Channels
- # announcements (1)
- # babashka (31)
- # babashka-sci-dev (53)
- # beginners (33)
- # calva (54)
- # cider (15)
- # clj-kondo (9)
- # clojure (115)
- # clojure-dev (19)
- # clojure-europe (21)
- # clojure-nl (1)
- # clojure-norway (78)
- # clojurescript (10)
- # clr (9)
- # community-development (9)
- # core-async (24)
- # cursive (18)
- # datomic (59)
- # emacs (43)
- # figwheel-main (2)
- # fulcro (4)
- # graphql (4)
- # malli (7)
- # meander (12)
- # nbb (14)
- # off-topic (22)
- # polylith (8)
- # re-frame (5)
- # reitit (3)
- # releases (1)
- # shadow-cljs (36)
- # sql (1)
- # tools-build (23)
- # xtdb (13)
I tried to use loadFile
to get access to functions from clojure which worked fine so far. However in my usecase js loads cljs from index.mjs
, cljs
then loads other javascript files which themselves access other parts of the cljs
.
It works apart from that apparently everything in the cljs
files gets re-evaluated and iām loosing atom states as the atoms are re-defined. Is this a usecase that is generally not supported by nbb
or is there a better way for js/cljs communication?
But only the .cljs
file that you load with loadFile
should be reloaded, not the ones it requires - if they are already loaded, then they should not be reloaded
Ah many thanks. This works!
const { register } = await loadString("(require '[test.registry :as r]) #js {:register r/register}");
although a bit verbose. Would a separate API-file for the use with loadFile
be ill-adviced?Can you confirm that when using loadString
on the first cljs file, does not reload the other cljs files? If it does, then it's a bug
Yes, I confirm. Like this it does not re-evaluate the namespace registry whereas when using loadFile
directly on the file for the namespace it did re-evaluate it.
That's not what I meant. I expect re-evaluation of the file argument to loadFile but not to its transitive dependencies
I don't think adding a JS API thing for everything is possible, but maybe we can document this.
Sorry, I misunderstood then. I did some tests with loadFile
to see if transitive dependencies were re-evaluated and can confirm they are not.