I have a database query that returns the list of indexes of objects for a certain day, i.e.:
getIndexesOfDay(day: Day): Flow<List<String>>
Now, I need to listen for details for each index, for instance:
getDetailsByIndex(index: String): Flow<Details>
So the question is: how can I accomplish this using Flows?
Two important constraints:
- Changes on the indexes should propagate to the final flow;
- Changes on any
Details
object should also update the flow.
What I have already tried:
getIndexesOfDay(todayDay)
.map { indexes ->
indexes?.map {
mIndex->
getDetailsByIndex(mIndex)
}
}
But it returns a Flow<List<Flow<Details>>>
instead of the desired Flow<List<Details>>
Appreciate any help!
asList()
is acceptable here. The docs forcombine
have no warning about leaking out the Array, and the source code shows they take care not to reuse Array instances. – Ahoufe