Is there sth `concatWith` for Flow?
# coroutines
p
Is there sth
concatWith
for Flow?
Like this
Copy code
kotlin
fun <T> Flow<T>.concatWith(other: Flow<T>): Flow<T> {
  return flow {
    collect { emit(it) }
    other.collect { emit(it) }
  }
}
o
well, if you put the two flows into another flow, you can
flattenConcat
but I think the general idea is to not add too many operators to the core API, and leave them as separate libraries that can be included
d
This is interesting I was looking for a
merge
function that takes a
vararg
of
Flow<T>
and outputs a new
Flow<T>
I guess I will have to write my own.
p
Yeah it's actually pretty smile, it's just a flow forEach launch collect emit loop