Fork me on GitHub
#clojurescript
<
2021-11-13
>
flowthing08:11:16

cljs.core/*loaded-libs* always seems to be nil:

λ clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.893"}}}' -M -m cljs.main -r
ClojureScript 1.10.893
cljs.user=> *loaded-libs*
nil
cljs.user=> (require 'clojure.set)
nil
cljs.user=> *loaded-libs*
nil
Is this expected? This page indicates that there should be something there: https://cljs.github.io/api/cljs.core/STARloaded-libsSTAR

thheller09:11:45

@flowthing this is expected yes. it is only available in self-hosted builds using the self-hosted compiler

flowthing09:11:32

OK, thanks! Do you know whether there's a way to get the same information with the non-self-hosted compiler?

thheller09:11:12

define "the same information"? all that data exists in the analyzer data in the compiler yes, getting to it dynamically at runtime however is a different story

flowthing09:11:39

I'll dig into the analyzer data, thanks. I suppose cljs.analyzer.api/all-ns is close enough, although I'm kinda hazy on the difference between (all-ns) and (loaded-libs) in Clojure, too.

thheller09:11:51

you cannot do the same stuff as in clojure. vars or namespaces technically don't really exist in the runtime so any kind of var based programming stuff is inherently limited

flowthing09:11:26

Yeah, I get that.

Dudley Craig12:11:39

don't s'pose someone could point me in the right direction regarding channels based promise handling ... const querySnapshot = await getDocs(collection(db, "users"));

Dudley Craig12:11:49

i've contrived the following as a terrible example of what I'm attempting ... (defn get-companies [] (let [channel (async/chan)] (try (async/go-loop [] (async/>! channel (.then (getDocs (collection (getFirestore) "companies")))) (async/close! channel) (catch js/Object error (.error js/console "Failed retrieving companies, " error)))) channel))