https://kotlinlang.org logo
#flow
Title
# flow
l

Landry Norris

07/28/2022, 4:29 PM
This may be a stupid question, but is there a concise way to convert a List<Flow<T>> to a Flow<List<T>> that emits a value when any flow in the list emits a value?
r

Robert Wijas

07/28/2022, 4:52 PM
combine
?
l

Landry Norris

07/28/2022, 4:53 PM
I didn’t notice that combine has the ability to take a list 🤦
d

DALDEI

08/07/2022, 3:03 PM
what do you want the resulting List<T> to contain ? I just worked out a similar question, the request was to have the resulting List<> be the concatenation of all prior elements. For that, scan() worked . If your case is similar then something like this, using merge+ scan val input = listOf( flow.....) input.merge().scan( emptyList() ){ a,b -> a + b }
Thata should produce a flow containing the successively longer list each time any of the input values are emitted
4 Views