In addition to mult/tap, if all you need is something that looks like a
promise, the newest core.async has "promise channels" which only accept a
single put, but that value can be retrieved by many takes.



On Wed, Nov 25, 2015 at 3:21 AM, Moe Aboulkheir <m...@nervous.io> wrote:

>
>
> On Wed, Nov 25, 2015 at 6:42 AM, <fah...@gmail.com> wrote:
>>
>> So how does one use channels if one is accustomed to registering several
>> callbacks to a single event? Do you have an intermediary which takes one
>> value from the source channel and then puts the value on as many other
>> channels as there are subscribers?
>>
>
> There is a construct specifically for this - mult/tap (create a mult of
> the source channel/s, tap the relevant ones onto a channel per listener).
> The pub/sub functions can also be used, if there is more complicated
> dispatching logic.  Further, if the events aren't coming in streams (i.e.
> one event per channel), the most recent release of core.async includes a
> promise-chan function, which supports single write, multiple read.  mult
> sounds like the right way to go, though.
>
>
>> And as for hooking up a single function to more than one channel, is that
>> where you'd use alts! ? But does that mean you have to know all the
>> channels you're interested in vs having the freedom to take the same
>> function and have it take from any additional channel?
>>
>
> If each the consumers has their own channel, you don't need to know within
> the consumer about the details of where the events are coming from.
>
> Take care,
> Moe
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to