Wednesday, June 19, 2019

Learning RxJava: Thoughts on Chapter 11

RxJava on Android

In short, Rx is extremely popular on mobile platforms, with RxJava being heavily used on Android and RxSwift being used on iOS.

One of the pain points, though, is that a large number of Android devices are still stuck with Java 6, which is missing lambda functions. The same thing can still be accomplished with anonymous classes, but they are extremely verbose. To fix this issue, you can use Retrolambda, which will allow you to use Java 8 style lambdas, but will then compile it to use anonymous classes in the byte code. Another option is just to forego Java altogether, and use Kotlin instead, which many developers have opted to do.

Two important libraries to include with android development are RxAndroid and RxBinding. The RxAndroid library has a handful of useful tools, primary of which are the Android Schedulers. With this you can switch between the main thread for UI elements and other threads for processing. RxBinding is an Rx wrapper for UI elements. There are also many other libraries available that can be useful depending on your use case. Go to https://github.com/ReactiveX/RxAndroid/wiki to see a list of these libraries.