Now I want to combine these two so I can expose an...
# coroutines
p
Now I want to combine these two so I can expose another channel of
data class Person(val userName : String, age : Int)
v
Now I want to combine these two so I can expose another channel of
data class Person(val userName : String, age : Int)
It’s actually not a
combineLatest
semantics. For the
combineLatest
I’d recommend using
select
operator, for merging two channels
kotlinx.coroutines
has zip operator: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.channels/zip.html
p
Why is it not a
combineLatest
semantic?
v
ch1: “John” ch2: 30 ch2: 32 combine latest over these two channels will produce
Person("John", 30), Person("John", 32)
, it’s not a desired behavior for a person example, is it?
p
Exactly that is desired
When the user changes it's age, that's the new state I want to render 🙂
v
oh, sorry then 🙂
l
@Paul Woitaschek Here's my solution, which works for any number of channels or callbacks, of any type: https://gist.github.com/LouisCAD/d9d1adbd3b4fd36d9dc121658fefd16f Let me know if you need help figuring out how to use it.
p
Thanks, after figuring out forever I implemented it in rx and it's way simpler
My conclusion so far is that with anything stream based, rx makes it simpler where with whenever I have a rx.Single / Maybe coroutines work better