This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-16
Channels
- # announcements (1)
- # babashka (26)
- # beginners (17)
- # clojure (18)
- # clojure-europe (4)
- # clojure-losangeles (1)
- # clojure-norway (42)
- # clojure-uk (3)
- # datalevin (3)
- # datomic (5)
- # fulcro (7)
- # funcool (2)
- # gratitude (1)
- # hoplon (15)
- # hyperfiddle (7)
- # lsp (5)
- # malli (12)
- # off-topic (3)
- # reitit (7)
- # releases (5)
- # remote-jobs (8)
- # shadow-cljs (21)
- # sql (9)
I've found myself in need of an async/merge
equivalent for csp chans. I've tried copying the the core async implementation, and it works for a toy example but doesn't work in my actual application, so I'm going to paste my translation here in case I've made an obvious error:
(defn merge
[chans & {:keys [buf xf exh exc] :as opts}]
(let [out (csp/chan opts)]
(csp/go-loop [cs (vec chans)]
(if (pos? (count cs))
(let [[v ch] (csp/alts cs)]
(if (nil? v)
(recur (filterv #(not= ch %) cs))
(do (csp/put out v)
(recur cs))))
(csp/close! out)))
out))