feroz_baig
07/25/2017, 11:14 AMrafal
07/25/2017, 11:19 AMfun <T, R> ReceiveChannel<T>.flatMap(context: CoroutineContext = Unconfined, onError: (Throwable) -> Unit = logOnError, mapper: suspend (T) -> ReceiveChannel<R>): ReceiveChannel<R> = produce<R>(context) {
try {
for (elem in this@flatMap)
for (mapped in mapper(elem))
send(mapped)
} catch (t: Throwable) {
onError(t)
}
}
flatMap
"operator"