This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-19
Channels
- # beginners (34)
- # boot (111)
- # cider (37)
- # clara (57)
- # cljsjs (1)
- # cljsrn (22)
- # clojure (156)
- # clojure-austin (2)
- # clojure-mke (7)
- # clojure-russia (9)
- # clojure-spec (221)
- # clojure-uk (47)
- # clojurescript (42)
- # code-reviews (4)
- # community-development (9)
- # core-async (3)
- # cursive (50)
- # datomic (81)
- # emacs (12)
- # events (5)
- # hoplon (1)
- # jobs (2)
- # lein-figwheel (4)
- # leiningen (1)
- # luminus (3)
- # mount (2)
- # off-topic (1)
- # om (94)
- # om-next (3)
- # onyx (33)
- # re-frame (23)
- # reagent (41)
- # remote-jobs (9)
- # rum (30)
- # slack-help (2)
- # specter (1)
- # untangled (20)
- # yada (17)
is it bug or is it OK that completing transducer function is called twice in channel?
(let [xf (fn [rf]
(fn
([] (println "INIT") (rf))
([result] (println "COMPLETING") (rf result))
([result input] (println "STEP") (rf result input))))
c (chan 10 xf)]
(close! c)
(println "RESULT" (<!! c)))
will print
COMPLETING
COMPLETING
RESULT nil
According to https://clojure.org/reference/transducers, it is probably a bug: > A completing process must call the completion operation on the final accumulated value exactly once
Looks like completing fn is called at there places in core.async: https://github.com/clojure/core.async/blob/master/src/main/clojure/cljs/core/async/impl/channels.cljs#L122 https://github.com/clojure/core.async/blob/master/src/main/clojure/cljs/core/async/impl/channels.cljs#L146