I am going to start using reactive programming in my Android project. I am using Kotlin as primary language and now I would like to apply Rx. My first choice was RxAndroid but then I noticed that there is RxKotlin.
As far as I know both are forked from RxJava so RxAndroid probably provides some API for android common tasks. On the other hand RxKotlin support lambas out of the box and allow me avoiding mixing kotlin with java.
Which one is preferred library in that case?
Coroutines are the perfect replacement for background threads or AsyncTask (Android). It's as easy as launch { someBlockingFunction() } . Of course you could achieve this with RxJava too, using Schedulers and Completable perhaps.
RxKotlin is a kotlin library built on top of RxJava that adds a basic lightweight extension function to RxJava, making it easier to work with in Kotlin. Kotlin Coroutines, on the other hand, are little threads that make asynchronous code execution easier.
The major difference between RxAndroid and RxJava is Schedulers. Schedulers are specifically available in RxAndroid not in RxJava which helps in efficient threading.
RxJava is a Java VM implementation of Reactive Extensions. where we can create asynchronous data stream on any thread, transform it and these asynchronous data streams can be consumed by Observers on any thread. What is RxKotlin? RxKotlin is a Kotlin implementation of Reactive Extensions.
You could use both of them. RxKotlin contains an extension functions that provides to you idiomatic way(with writing less code) of using rxJava in Kotlin. rxAndroid(is now split in few libraries) provides specific platform bindings such as:
There are few more useful libraries for rxJava and Android you could be interested.
Edited 01.04.16
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With