I tried to search for it but with no luck. How to ...
# coroutines
d
I tried to search for it but with no luck. How to combine more than 5 flows?
k
https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/combine.html There's an overload that receives 5 flows, and even another one with a variadic amount of flows, though I'd hesitate to combine that many flows, seems like a design flaw.
PS: For the overload with
vararg
you'll receive your flows inside an
Array
instead of receiving them as separate values
d
But all `vararg`s needs to be in a type of T
k
Make them
Flow<Any>
And as you can see, it's already getting cumbersome to do so, you should probably first consider changing the code there to avoid combining more than 5 flows
l
Consider using the Molecule library by Square if it fits your needs.
l
good tips above! When i had this issue, I created a custom combine with 6 parameters. another solution could be, if possible, to combine 2 or more in an intermediate flow, and using this combined result in your “final” combine.