igorvd
10/09/2019, 5:20 PMtseisel
10/09/2019, 6:45 PMigorvd
10/09/2019, 7:53 PMVlad
10/09/2019, 10:37 PMchannelFlow
to combine multiple flows. Something like this:
fun <T> mergeFlows(vararg flows: Flow<T>): Flow<T> {
return channelFlow {
for (flow in flows) {
launch { flow.collect { offer(it) } }
}
}
}
gildor
10/09/2019, 11:43 PMigorvd
10/10/2019, 11:38 AMVlad
10/10/2019, 12:05 PMflattenMerge
is a more thought out version of what I had - you will end up in a channel flow where the flow of flows is unpacked:
flowOf(flow1,flow2, flow3, flow4).flattenMerge()
They have to conform to a shared type thought.igorvd
10/10/2019, 6:18 PMcombine
operation, something like that:
val combinedFlow = shareFlow
.combine(latestTransactionFlow) {
share, transaction -> share to transaction
}
.combine(biggestTransactionFlow) { pair, biggestTransaction ->
Triple(pair.first, pair.second, biggestTransaction)
}