Fork me on GitHub
#aleph
<
2017-11-10
>
karlis14:11:33

Hi all! This is more of a manifold question, but I'll ask this here: are there easy ways to transform a deferred to a core.async promise channel? after quick read through docs all interfacing with core.async happens through streams.

dm316:11:37

I think you have to go through streams or create something yourself, like:

(defn deferred->chan [d] (let [c (async/chan)] (d/on-realized d #(async/put! c [:value %]) #(async/put! c [:error %])) c))

mpenet16:11:47

you can use an async/promise-chan for extra points

mpenet16:11:55

saves some resources too