I have a data class, MyThing1, which has an ID in it. data class MyThing1(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 function 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) .
and where every times myThing1 changes, it observes myEmitter2(id) and every time myThing2 emits, it emits a CombinedThing.
In a diagram, I'd like something like this:
[mt11,mt12]--------------------------------------------------------------------------
observe for id 1 ----mt211-----------------------------------------------------------
--[observe for id 2]------------------------mt212-------------------------------------
---------------------[CT(mt11,mt211(1))]----[CT(mt11,mt211(1)),CT(mt2,mt212)]---------