This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-12
Channels
- # announcements (13)
- # aws (18)
- # babashka (60)
- # babashka-sci-dev (83)
- # beginners (32)
- # biff (18)
- # calva (22)
- # cider (8)
- # clj-on-windows (101)
- # clojure (59)
- # clojure-bay-area (2)
- # clojure-europe (36)
- # clojure-india (4)
- # clojure-nl (3)
- # clojure-norway (5)
- # clojure-spec (4)
- # clojure-uk (1)
- # clojurescript (5)
- # conjure (1)
- # core-async (10)
- # cursive (7)
- # data-science (5)
- # datahike (10)
- # datalog (11)
- # datomic (3)
- # docker (3)
- # figwheel-main (2)
- # gratitude (3)
- # improve-getting-started (1)
- # introduce-yourself (5)
- # jobs (3)
- # joyride (12)
- # leiningen (1)
- # lsp (67)
- # malli (27)
- # off-topic (36)
- # random (1)
- # rdf (1)
- # re-frame (17)
- # reagent (21)
- # reitit (4)
- # releases (4)
- # remote-jobs (2)
- # ring (2)
- # sci (35)
- # shadow-cljs (28)
- # sql (3)
- # squint (9)
- # tools-deps (11)
Is it the correct way to concat channels?
(defn- concat-chs [chs]
(let [ch (a/chan)]
(a/pipeline-async 1 ch a/pipe (a/to-chan! chs))
ch))
For 2 channels, something like
(defn concat2
[x y]
(let [ch (a/chan)]
(a/go
(loop []
(let [a (a/<! x)]
(if (nil? a)
nil
(when (a/>! ch a)
(recur)))))
(loop []
(let [a (a/<! y)]
(if (nil? a)
(a/close! ch)
(when (a/>! ch a)
(recur))))))))
Then reduce over n channels?Is it correct that I should never ever use put!
/`take!` and always use >!
/ <!
in go blocks because put!
/`take!` might throw while <!
/`>!` will park on backpressure and because of that have more chances to recover?
Error handling could be better… core.async:
(<!! (a/reduce + 0 (a/to-chan! [1 2 3 4 5 "" 6])))
=> nil
manifold:
@(stream/reduce + 0 (stream/->source [1 2 3 4 5 "" 6]))
throws=> ClassCastException...
What the approach to error handling should be if I use core.async? Wrap everything in try catch? Shouldn’t async functions like a/reduce
/`a/map` etc. accept an error handler like a/chan
does?