alexfacciorusso
07/26/2021, 8:45 AMMyThing1(val id: String)
I have another data class which we don’t care about its content, but let’s call it MyThing2
I have a Flow, that returns a list of MyThing1 fun myEmitter1(): Flow<List<MyThing1>>
I have another Flow that takes in input an ID and returns a flow of objects, so fun myEmitter2(id: String): Flow<MyThing2>
For each MyThing1 received from the flow, I want to combine it with the latest MyThing2 that gets emitted by myEmitter2
and return a Flow<List<CombinedThing>>
given the CombinedThing is data class CombinedThing(val myThing1: MyThing1, val myThing2: MyThing2)
.
Any thought for doing it efficiently?Nick Allen
08/02/2021, 10:45 PMmyEmitter.flatMapLatest { myThing1 ->
myEmitter2(myThing1.id).map { CombinedThing(myThing1, it}
}