enleur
01/26/2018, 5:11 PMfun <E> ReceiveChannel<E>.onEach(context: CoroutineContext = Unconfined, action: (E) -> Unit): ReceiveChannel<E> =
produce(context) {
consumeEach {
action(it)
send(it)
}
}
r4zzz4k
01/26/2018, 5:51 PMmap()
which does the same under the hood. Two things I don't really like about this:
1. I need to pass capacity
as map()
creates produce(capacity = 0)
2. I'm creating several `Channel`s, which are passed as ReceiveChannel
in one place and SendChannel
in the other one, so I have to put this onEach
specifically on ReceiveChannel
side, which isn't very convenient.
So I'll probably stick with derivative class for debugging purposes for now.