Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(require '[clojure.core.async :as ca])
(def some-ch (ca/chan))
(def result-ch (ca/reduce
(fn [xs msg]
(if (= msg :done)
(reduced xs)
(conj xs msg)))
[]
some-ch))
(ca/put! some-ch :a)
(ca/put! some-ch :b)
(ca/put! some-ch :done)
(ca/<!! result-ch) ;;[:a :b]
(ca/put! some-ch :c)
(ca/<!! some-ch) ;; :c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment