Kotlin coroutines can be a powerful replacement for RxJava in an Android project.
Do you agree?
Looking for some interesting things from all android devs.
Please comment, reply, write, add....
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (3)
I'm still fairly new to both Kotlin coroutines and RxJava, but it seems to me like they serve different purposes. Coroutines are really great for making async code feel like you're writing it synchronously, but it still is mostly just writing code. Where RxJava really shines is in data transformation, and helping you structure code to making a very clear pipeline of data flow.
Coroutines are really nice for doing things like making quick HTTP requests or DB queries off the main thread with very little cognitive overhead, because you're still just writing code, it's just inside of a closure.
I've found RxJava to be really nice for doing things like chaining multiple HTTP requests together inside a single service. For example, hitting one API to login, piping that to another API to fetch detailed profile information, and then finally piping that to a function which caches the response in our DB, and each stage accepts a different object type and must be transformed from one to the next as it goes along. RxJava makes this kind of code transformation very readable and easily understandable, but definitely comes with a bit of overhead and isn't right for every situation.
Thanks Casey. I was confused about this. Your reply is good.
The headline differs much from the question here...
IMO, Kotlin itself can make our life better because it works around most of Java's shortcoming while still providing full interoperation with it.