why flatMapMerge/flatMapConcat are not recommended
Who says they’re not recommended? 🤔 Perhaps they meant that they’re often not exactly what you want: if you use
flatMapMerge
, then all of the flows you emitted are active at the same time, and their emissions are merged.
That is if you have
fn(x) = flowOf(x1, x2, x3, …)
and do
flow.flatMapMerge { fn(it) }
then if
flow
emits
a, b, c, d, e
then after flat map you’l be getting
a1, b1, a2, c1, c2, b2, a3, b3
etc. Previously emitted flows don’t get cancelled