This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-05
Channels
- # beginners (240)
- # boot (5)
- # cider (48)
- # clara (2)
- # cljs-dev (3)
- # cljsrn (66)
- # clojure (111)
- # clojure-denver (2)
- # clojure-italy (42)
- # clojure-nl (5)
- # clojure-spec (12)
- # clojure-uk (45)
- # clojurescript (138)
- # community-development (7)
- # core-async (8)
- # datomic (27)
- # emacs (21)
- # euroclojure (6)
- # figwheel (10)
- # fulcro (29)
- # graphql (5)
- # hoplon (3)
- # luminus (1)
- # lumo (7)
- # mount (4)
- # off-topic (13)
- # onyx (20)
- # parinfer (3)
- # pedestal (4)
- # precept (1)
- # proton (3)
- # re-frame (41)
- # reagent (3)
- # reitit (28)
- # ring-swagger (7)
- # shadow-cljs (88)
- # specter (1)
- # testing (10)
- # tools-deps (27)
- # vim (58)
Is there a way to consume messages from a core.async channel multiple times in CLJS?
@stephenmhopper like read a message without “removing” it from the channel?
@matthavener Yeah. I was mostly asking with regard to caching cljs-http responses that I'm getting as single responses on a core.async channel. I discovered that I could just pipe
that channel to a promise-chan
to achieve the desired effect. However, I'm still curious if there's a general way to read from a channel without consuming in CLJ (not just CLJS). Can I use eduction
to achieve that effect?
it looks like a promise-chan
, as you found, is exactly what you want. it’s a channel with a buffer implementation where reading doesn’t remove the value from the buffer. https://github.com/clojure/core.async/blob/master/src/main/clojure/cljs/core/async/impl/buffers.cljs#L145
you cannot in general perform a take
on a channel without consuming the item, but a buffer can choose to supply the channel with the same value endlessly
hm, not sure about eduction, but you could wrap the channel in a buffer
a chan can be totally unbuffered
you can’t read without consuming