This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-02
Channels
- # ai (1)
- # aleph (16)
- # announcements (1)
- # architecture (51)
- # babashka (32)
- # beginners (27)
- # calva (3)
- # clerk (1)
- # clojure (49)
- # clojure-art (1)
- # clojure-denver (6)
- # clojure-europe (70)
- # clojure-nl (1)
- # clojure-norway (56)
- # clojure-uk (2)
- # clojuredesign-podcast (4)
- # clojurescript (57)
- # clr (15)
- # community-development (3)
- # conjure (1)
- # core-async (10)
- # data-science (1)
- # datalog (2)
- # datomic (3)
- # emacs (12)
- # events (1)
- # gratitude (4)
- # honeysql (9)
- # hyperfiddle (86)
- # jobs (4)
- # off-topic (10)
- # pedestal (5)
- # portal (11)
- # practicalli (2)
- # reitit (7)
- # releases (3)
- # remote-jobs (1)
- # sql (15)
- # tools-build (8)
- # xtdb (4)
Why is timeout
in CLJS not just,
(defn timeout
[ms]
(let [ch (chan)]
(js/setTimeout #(close! ch) ms)
ch))
I see that there’s a lot of stuff happening in the implementation, so I assume the above is naive, but I don’t understand why.The reason I’m asking is because I’m running into weird behaviour with timeout
, where closing one timeout seems to close another, unrelated one (no pipe
s etc. involved, or other things that might propagate), and the naive version seems to work as expected.
If you were going to change how timeouts are implemented in cljs I wouldn't go with exactly that, it perpetuates a big issue with the current design of timeouts, a strong reference to the timeout channel is kept by the global system that closes the timeout channels
https://clojure.atlassian.net/browse/ASYNC-109 I forgot about this, which has a cljs patch as well