Anyone here who worked with coroutines, please sha...
# announcements
f
Anyone here who worked with coroutines, please share your opinions. If familiar with RxJava2, please contrast both of them as well
r
Creating custom operator is waaaaay easier with coroutines. So creating e.g. rx-like operator is a breeze
Copy code
fun <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)
    }
}
that's all it took for me to create
flatMap
"operator"
👍 1
Also ask for other opinions on #coroutines as my opinion might be somehow biased