Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use RxAndroid or RxKotlin when programming in Kotlin for Android? [closed]

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?

like image 838
Damian Petla Avatar asked Nov 17 '14 08:11

Damian Petla


People also ask

How Kotlin coroutines are better than RxKotlin RxJava?

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.

What is RxKotlin used for?

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.

What is the difference between RxJava and RxAndroid?

The major difference between RxAndroid and RxJava is Schedulers. Schedulers are specifically available in RxAndroid not in RxJava which helps in efficient threading.

What is difference between RxJava and RxKotlin?

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.


Video Answer


1 Answers

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:

  • rxAndroid that could help you to manage an execution with native android Handlers
  • rxLifecycle that provides Activity lifecycle bindings
  • rxBinding and rxBinding-kotlin that helps to manage UI with all power of rxJava

There are few more useful libraries for rxJava and Android you could be interested.

Edited 01.04.16

like image 141
Stepango Avatar answered Sep 18 '22 12:09

Stepango