Hi everyone, I'm starting to use coroutines in pro...
# coroutines
m
Hi everyone, I'm starting to use coroutines in prod and could use a bit of advice. I need to observe state of couple of components, both should offer subscribe/unsubscribe ops. I'm thinking of having a channel for each, created on subscription, canceling does the unsubscribe, and observe both using
select
. Is that fine? Are there any channel constructs that could help?
g
Probably better to use Flow for this
but you also can use Channel
But if you need select for Channel, so probably you need something like combineLatest for Flow, but it’s not available yet in the latest version, but probably will be in upcoming. PR already opened https://github.com/Kotlin/kotlinx.coroutines/issues/1193
m
what's the status of Flow, I'm writing a library here and I don't have full control of coroutine lib version, so I'm trying to use only stable APIs
g
Channels are also Experimental, some operators marked as Obsolete
so I don’t think that situation is very different
I would just use Flow
m
Isn't just subset of channel API experimental?
g
Yes, subset
but this “subset” is actually all operators, many methods of Channel, whole BroadcastChannel API
you probably can avoid using them, but it will be not easy