This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-19
Channels
- # announcements (5)
- # babashka (49)
- # beginners (11)
- # biff (5)
- # calva (123)
- # clerk (9)
- # cljdoc (5)
- # cljs-dev (9)
- # clojure (62)
- # clojure-europe (32)
- # clojure-nl (1)
- # clojure-norway (54)
- # clojure-uk (3)
- # clojurescript (30)
- # community-development (5)
- # cursive (9)
- # devops (5)
- # events (1)
- # fulcro (35)
- # graalvm (10)
- # gratitude (3)
- # hyperfiddle (9)
- # jobs (3)
- # keechma (1)
- # lsp (10)
- # malli (14)
- # off-topic (42)
- # overtone (1)
- # releases (3)
- # shadow-cljs (66)
- # squint (153)
- # xtdb (19)
Has anyone created a watchable reference in a web worker. I essentially want to be able to run some compute on a web worker which puts results in an atom. Which is watched from the main thread.
Assuming you already have a worker set up:
(def worker-data (atom nil))
(set! the-worker -onmessage #(reset! worker-data (.-data ^js %)))
you probably want to serialize stuff back and forth. doubt you are just gonna send js data
I looked at this more the ideal solution is transferring ownership of an ArrayBuffer if I go in this direction. My thoughts was actually if someone had wrapped SharedArrayBuffer with IWatachable or something.
IMHO that is nonsense unless you actually just sharing binary data. CLJS datastructures are not binary data, so either way you are going to serialize them. if you serialize them you might as well just transfer a string, eg. edn or transit.
FWIW JS doesn't have enums. its just a javascript object, so the same interop rules like any other JS object apply
The required namespace "goog.crypt.base64.Alphabet" is not available, it was required by
@U05224H0W I was worried that might not work across compilation styles 😄
:import
was added a long time ago to solve a specific problem - when the namespace is a constructor
but since we added using :as
aliases as "vars" this became redundant no? ["some.thing" :as x]
(x.)
works now, same for closure lib
all stuff that came way later - there’s too little value in changing this kinds of really old decisions
I'm not saying to change it at all. just saying that :require
now covers everything :import
previously did, so it is no longer "required" to use
Is it worth updating the documentation around how to use the closure library if :require
can now do it in place of :import
?
agree with dominic. there are cases I have used :import
where :require
is sufficient. itd be nice to reflect "modern clojurescript" in official documentation.
note that there is technically nothing wrong with :import
and it is fine to use. the only problem is that the closure library is somewhat inconsistent in how things are structured. so some things are actual "namespaces" while others are just "vars" (as in property of the namespace) or even properties of other vars. so while :import
might work for some it won't for others. :require
is a bit more forgiving that way, but still not immune either.