Fork me on GitHub
#core-async
<
2017-01-19
>
wagjo13:01:44

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

wagjo13:01:51

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