This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-05
Channels
- # babashka (14)
- # beginners (62)
- # calva (1)
- # cider (54)
- # clj-kondo (3)
- # cljdoc (15)
- # cljs-dev (2)
- # clojure (180)
- # clojure-europe (5)
- # clojure-italy (4)
- # clojure-losangeles (1)
- # clojure-nl (2)
- # clojure-spec (10)
- # clojure-uk (39)
- # clojurescript (85)
- # core-async (9)
- # core-logic (1)
- # core-typed (5)
- # data-science (27)
- # datomic (2)
- # emacs (15)
- # figwheel-main (98)
- # fulcro (26)
- # graphql (15)
- # helix (1)
- # jobs-discuss (26)
- # kaocha (1)
- # off-topic (54)
- # other-lisps (1)
- # re-frame (21)
- # reagent (1)
- # reitit (3)
- # shadow-cljs (49)
- # spacemacs (12)
- # specter (5)
- # xtdb (2)
There is a implementation of "broadcast" in core.async? I mean, when I put into a channel, all listeners will receive the message
(let [pub-port (async/chan)
pub (async/pub pub-port (constantly ::all))
sub-port (async/chan)
sub (async/sub pub ::all sub-port)]
(async/go
(prn [1 (async/<! sub)]))
(async/go
(prn [2 (async/<! sub)]))
(async/put! pub-port "hello"))
On this example, just 1 or 2 will be printed. I want both.There is no examples of use of mult
@hiredman
I tryied in this way
(let [pub-port (async/chan)
mult (async/mult pub-port)
sub-port (async/chan)]
(async/tap mult sub-port)
(async/go
(prn [1 (async/<! sub-port)]))
(async/go
(prn [2 (async/<! sub-port)]))
(async/put! pub-port "ok"))
With the same result of pub/sub
Looking for this: https://github.com/clojure/core.async/blob/master/src/test/cljs/cljs/core/async/tests.cljs#L263 My solution looks right.
(letfn [(listen [m]
(let [c (async/chan)]
(async/tap m c)
c))]
(let [pub-port (async/chan)
mult (async/mult pub-port)]
(async/go
(let [c (listen mult)]
(prn [1 (async/<! c)])))
(async/go
(let [c (listen mult)]
(prn [2 (async/<! c)])))
(async/go
(async/>! pub-port "ok"))))
This listen
function make sense? It's implemented somewhere?