mix

added

ns
clojure.core.async

type
function

(mix out)

Creates and returns a mix of one or more input channels which will
be put on the supplied out channel. Input sources can be added to
the mix with 'admix', and removed with 'unmix'. A mix supports
soloing, muting and pausing multiple inputs atomically using
'toggle', and can solo using either muting or pausing as determined
by 'solo-mode'.

Each channel can have zero or more boolean modes set via 'toggle':

:solo - when true, only this (ond other soloed) channel(s) will appear
in the mix output channel. :mute and :pause states of soloed
channels are ignored. If solo-mode is :mute, non-soloed
channels are muted, if :pause, non-soloed channels are
paused.

:mute - muted channels will have their contents consumed but not included in the mix
:pause - paused channels will not have their contents consumed (and thus also not included in the mix)

                user=> (def ch-out (chan))
#'user/ch-out

user=> (def mix-out (mix ch-out))
#'user/mix-out

user=> (def ch-example1 (chan))
#'user/ch-example1

user=> (def ch-example2 (chan))
#'user/ch-example2

user=> (admix mix-out ch-example1)
true

user=> (admix mix-out ch-example2)
true

user=> (put! ch-example1 "sent to chan 1")
true

user=> (put! ch-example2 "sent to chan 2")
true

user=> (<!! ch-out)
"sent to chan 1"

user=> (<!! ch-out)
"sent to chan 2"