This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-20
Channels
- # adventofcode (38)
- # announcements (8)
- # aws (4)
- # babashka (131)
- # beginners (263)
- # calva (2)
- # clj-kondo (12)
- # cljdoc (12)
- # cljsrn (3)
- # clojure (122)
- # clojure-europe (3)
- # clojure-finland (2)
- # clojure-nl (13)
- # clojure-uk (80)
- # clojured (1)
- # clojuredesign-podcast (3)
- # clojurescript (78)
- # core-async (19)
- # cursive (19)
- # datomic (7)
- # duct (10)
- # events (1)
- # fulcro (7)
- # graalvm (12)
- # graphql (3)
- # juxt (4)
- # malli (10)
- # music (3)
- # nrepl (4)
- # off-topic (25)
- # pathom (4)
- # pedestal (1)
- # re-frame (78)
- # reagent (8)
- # shadow-cljs (91)
- # sql (8)
- # vim (3)
- # xtdb (2)
> * After a put, all pending takes are notified, and any subsequent takes return the put value immediately > * After a close (and no put), all pending takes are notified with nil, and any subsequent takes return nil immediately
in my case in particular I was surprised by the put! return value on undelivered/already delivered/closed promise-chan
In short:
(-> (doto (async/promise-chan)
(async/>!! :foo)
(async/close!))
(async/put! :bar))
false
vs
(-> (doto (async/promise-chan)
(async/>!! :foo))
(async/put! :bar))
true
promise-chans are inherently multi listener (as all channels). there are two cases - a value is delivered, or the chan is closed. All pending listeners receive either the value, or nil.
right now there's a 3rd case, the value is delivered and the chan is close!d. I get why we have close! for an "empty" promise-chan, it's just a bit weird when it's already realized
@fmjrey I am fine with that, it's for convenience and a way to know if it's already closed
For the record: https://clojure.atlassian.net/browse/ASYNC-103