June 2018
Intermediate to advanced
316 pages
6h 34m
English
You can easily combine your code written in a reactive style with coroutines. For this, you can use the kotlinx-coroutines-rx2 module (https://github.com/Kotlin/kotlinx.coroutines/tree/master/reactive/kotlinx-coroutines-rx2).
This library contains a set of functions to convert coroutines to live collections from RxJava, such as rxMaybe, rxCompletable, rxSingle, rxObservable, and rxFlowable.
Or you can, for instance, invoke an await* family method of a live collection from RxJava. We can use this with our reactiveOrder method:
suspend fun rxToCoroutinesOrder(amountOfCakes: Int): List<Cake> { return reactiveOrder(amountOfCakes).await()}
We can invoke this method using the following code:
fun main(args: Array<String>) ...
Read now
Unlock full access