Closed kul closed 10 years ago
This is covered in the README. Take a look at the port
and subscribe
functions.
@weavejester i am being thick here it seems, so given an core.async channel ch
which is being >!'d from somewhere else, how do i get a stream out of it?
So i had a crack at it, obviously it is not implemented as protocol methods which are there in reagi.core, but here is what i am trying to do
(defn publish
[stream channel]
(go (loop [m (<! channel)]
(if m (r/deliver stream m) (r/completed nil))
(when m (recur (<! channel))))))
You can use the port
function from Reagi, and the pipe
function from core.async:
(a/pipe channel (r/port stream))
Thanks!
I am not sure if i am missing the obvious but how can i treat a core.async channel as a event stream? Would it make sense to have
(publish stream channel)
where channel is publishing to stream, instead of subscribing like in(subscribe stream channel)
and is completed? when channel closes.