Fork me on GitHub

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.


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

Alex Miller (Clojure team)16:04:10

you can’t read without consuming