so, if i wanted a buffering behaviour to a `Broadc...
# coroutines
g
so, if i wanted a buffering behaviour to a
BroadcastChannel
, how might I get it? eg:
Copy code
val bufferedBroadcastChannel = bufferedBroadcastChannel<Int>();

launch(UI) { dispatchToStdOut(bufferedBroadcastChannel) }

bufferedBroadcastChannel.send(1)

launch(CommonPool) { dispatchToFile(bufferedBroadcastChannel) }

bufferedBroadcastChannel.send(2)

//...

fun dispatchToStdOut(channel: Channel<Int>){
  channel.consumeEach {
    println(it)
  }
}

fun dispatchToFile(channel: Channel<Int>){
  channel.consumeEach {
    file.writeLine(it)
  }
}
which outputs
Copy code
1
2
and also puts that in a file