svenjacobs
08/30/2019, 6:15 AMval flow1 = flowOf(1, 2, 3)
val flow2 = flowOf(4, 5, 6)
val flow3 = flow1.concat(flow2) // = 1, 2, 3, 4, 5, 6
The order of flow3 does not matter here, so it also might be 1, 4, 2, 5, 3, 6 or any other order, depending on how the values are produced in flow1 and flow2.svenjacobs
08/30/2019, 6:20 AMval flow3 = flow {
flow1.collect { emit(it) }
flow2.collect { emit(it) }
}
is a solution but I'm wondering if there is a simpler solution 😉louiscad
08/30/2019, 6:26 AMflatMapConcatsvenjacobs
08/30/2019, 6:34 AMFlow in the transform function will be applied to any value of flow1. So if I call flow1.flatMapConcat { flow2 } the result will be 4, 5, 6, 4, 5, 6, 4, 5, 6svenjacobs
08/30/2019, 6:48 AMflow1 and flow2 should only be there once in the resulting flow 😉marstran
08/30/2019, 7:07 AMflowOf(flow1, flow2).flattenConcat()svenjacobs
08/30/2019, 7:09 AMsvenjacobs
08/30/2019, 7:23 AMflow1 for instance needs 5 seconds before producing the first value but flow2 is faster? Then the first results will still be collected once flow1 has produced it's values. Also what if any of the flows are not terminal?marstran
08/30/2019, 7:35 AMflattenMerge().