If I have a Deferred what is the recommended way to "convert" it to core.async channel?
(go @deferred)
? But be aware if the deferred is blocked on IO
Aah, of course. How would that work in case of Manifold stream?
(let [chan (async/chan)]
(m.s/consume #(async/put! chan %) stream))
That solves the incoming part. What about outgoing? I have a duplex stream
You can simply convert via (m.s/->source chan)
be aware that with async/put!
method above there’s no backpressure so the chan
might be overwhelmed (depending on the buffer used)
you’d probably want to use stream/consume-async
and put!
with more options to respect backpressure/closing of chan
https://clojure.github.io/core.async/#clojure.core.async/put!
Thanks. My case is following. I am going to use Aleph for tcp server and client. However, I would like to work with core.async channels instead of Manifold streams.