flattenMerge() works much like
flattenConcat() from the previous lesson.
However, it takes a
concurrency parameter. If that is set to
flattenMerge() should give you identical output to
flattenConcat() is more efficient. However, if
concurrency is set to a higher
value — it defaults to
16 on Kotlin/JVM, for example — then instead
of the inner flows being subscribed to serially, they are subscribed to
concurrently, up to the requested level of concurrency.
So, this sample is identical to the
flattenConcat() one, other than the
flattenMerge(). However, due to concurrency, instead of getting
1 objects followed by all the
2 objects and so on, we get interleaved