Fork me on GitHub
#aleph
<
2017-07-12
>
mhjort16:07:33

If I have a Deferred what is the recommended way to "convert" it to core.async channel?

dm316:07:48

(go @deferred)? But be aware if the deferred is blocked on IO

mhjort16:07:32

Aah, of course. How would that work in case of Manifold stream?

dm316:07:07

(let [chan (async/chan)]
  (m.s/consume #(async/put! chan %) stream))

mhjort16:07:18

That solves the incoming part. What about outgoing? I have a duplex stream

dm316:07:20

You can simply convert via (m.s/->source chan)

dm316:07:16

be aware that with async/put! method above there’s no backpressure so the chan might be overwhelmed (depending on the buffer used)

dm316:07:32

you’d probably want to use stream/consume-async and put! with more options to respect backpressure/closing of chan

mhjort17:07:59

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.