This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-08
Channels
- # announcements (42)
- # aws (2)
- # babashka (69)
- # beginners (38)
- # calva (18)
- # cider (39)
- # circleci (1)
- # clj-commons (10)
- # cljs-dev (2)
- # clojure (36)
- # clojure-australia (14)
- # clojure-europe (25)
- # clojure-gamedev (40)
- # clojure-losangeles (4)
- # clojure-nl (5)
- # clojure-sweden (1)
- # clojure-uk (5)
- # clojurescript (133)
- # core-logic (24)
- # cursive (7)
- # datalevin (4)
- # datascript (3)
- # figwheel-main (1)
- # fulcro (45)
- # honeysql (1)
- # integrant (43)
- # introduce-yourself (1)
- # jobs (4)
- # leiningen (3)
- # lsp (32)
- # nextjournal (9)
- # pathom (18)
- # polylith (21)
- # portal (65)
- # re-frame (6)
- # releases (1)
- # remote-jobs (1)
- # reveal (12)
- # rewrite-clj (1)
- # sci (84)
- # tools-deps (22)
I am having trouble with evals that involve js classes. I use sci in browser, and have this config: :classes {'js goog/global :allow :all}
I exported j/get and j/call from applied-science/js-interop and this is working: (-> (j/get js :console) (j/call :log 34)) But both of this is getting the error symbol not found: (.log js/console "hi") js/Math.PI
@hoertlehner don't use :bindings
, just the :classes
config should make this work. Instead use :namespaces
to include js-interop
you can also make a repro repository and I'll take a look if you don't find what you need after these hints
so if I do not export js in bindings, then the eval of js/Math.PI gets me "Could not resolve symbol: js/Math.PI"
(defn compile-code [code] (try {:result (sci/eval-string code ctx-repl)} (catch :default e ;(error "sci compile-code --]" code "[-- ex: " e) {:error {:root-ex (.-data e) :err (.-message e)}})))
Thanks @borkdude I woul dnever have found out the eval-string* vs eval-string difference.
In goldly, I have an extension system, and there are many files that only ship sci code
but this approach only works while the number of files that have sci source code are small.
@hoertlehner #nbb has an async way of loading JS files. This is implemented by manually handling all top level expressions. When the top level is ns
or require
it provides its own async implementation and for the rest of the expressions it just invokes SCI as usual. Eventually that may come to SCI but right now it's incubating in that project.
So far the nbb approach is quite nice, but it's based on promises and promises might be controversial vs callbacks for example
So it's a bit too early to decide on a good approach. Instead I might document how its done in nbb so people can just borrow that approach
In goldly I have an extension system, where ui render functions can be included to the sci ui dynamically.
And when using this libraries, I do not want to return first a value that says loading.