https://kotlinlang.org logo
#coroutines
Title
# coroutines
h

henrikhorbovyi

11/20/2019, 12:48 PM
[
QUESTION
] Hello mates, I always hear people saying that RxJava is really powerful and coroutines it's a lighter solution. And they say that the situation to use RxJava is when you should use all those Rx operations (e.g.
transform, map, etc
). Thinking about this I was wondering if it's possible to do the same only with Coroutines and pure Kotlin, and if not, what is it so powerful in Rx?
c

christophsturm

11/20/2019, 12:49 PM
where do people say that?
h

henrikhorbovyi

11/20/2019, 12:49 PM
Those who use Rx
I've done things with Rx, but in a legacy project
I was just following the stack and patterns of the project
But in a new project I'm using Coroutines (I'm in love ❤️)
c

christophsturm

11/20/2019, 12:51 PM
its maybe better if you post an example of a powerful rx construct and ask how to do that in coroutines
h

henrikhorbovyi

11/20/2019, 12:52 PM
But even when I go to Kotlin events and they talk about Coroutines they say: Look, coroutines are beautiful, but still Rx is more powerful
That's the point @christophsturm 😄 I don't know what is not possible to do with Coroutines.
I never used all those Rx operations
I just made web requests, and ok, maybe transformed some data into another
s

streetsofboston

11/20/2019, 12:54 PM
It's both a pro and a con for Rx, but due to its large API, it is more 'powerfull' because it offers more functionality. Before the Flow API in coroutines, Rx was more powerful. But with Flow, it's only the Rx' API surface that gives it its edge.
h

henrikhorbovyi

11/20/2019, 12:55 PM
But I could do the same transform with kotlin map function
m

marstran

11/20/2019, 12:55 PM
Coroutines is a really flexible construct. I doubt you can find anything in Rx that you just can't do with coroutines.
s

streetsofboston

11/20/2019, 12:56 PM
99% of async in Android is one-shot operations. Rx uses Completable, Single or Maybe. Coroutines can just use 'suspend' functions
☝️ 5
h

henrikhorbovyi

11/20/2019, 12:57 PM
I always try to say this to people @marstran, but they didn't tried
Flow
😄 as @streetsofboston mension, so they can't understand what Coroutines are able to do now
s

streetsofboston

11/20/2019, 12:59 PM
But if your team consists of more than just Android devs (eg iOS), Rx may still be your choice, since its concepts are the same across platforms.
h

henrikhorbovyi

11/20/2019, 1:00 PM
Got it
d

Dariusz Kuc

11/20/2019, 2:57 PM
well there are certain things that are easier in RX/Reactor but for the most part coroutines are easier to reason about
e.g. afaik there is no built in construct in coroutines that would allow you to conditionally cancel one of the calls (amb operator)
but that is pretty fringe case
3 Views