This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
Practicing simple async stuff is there any errors in my code, what can be improved? I know about transducers.
(defn channel-transform [f] (fn [in] (let [out (chan)] (go-loop  (if-let [v (<! in)] (do (>! out (f v)) (recur)) (close! out))) out))) (def upper-caser (channel-transform str/upper-case)) (def reverser (channel-transform str/reverse)) (comment (let [in (async/to-chan ["hello" "world"]) out (reverser (upper-caser in))] (go-loop  (when-let [v (<! out)] (println v) (recur)))))
@nxtk i like it, I assume
f can't throw an exception and it's ok for
out to not have a buffer?
@danboykis its just an example i don't have any requirements, but that interesting to think about
any reason for missing counterparts of untap-all and unmix-all to add collections\seqs of channels to a mix\mult?
presumably because untap-all is able to untap channels you potentially don't even know about, but if you're using tap you have to know all the channels and can just map over the collection