https://kotlinlang.org logo
#coroutines
Title
# coroutines
p

Paul Woitaschek

05/02/2019, 8:36 AM
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

octylFractal

05/02/2019, 8:39 AM
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

dewildte

05/04/2019, 6:37 PM
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

Paul Woitaschek

05/05/2019, 12:34 PM
Yeah it's actually pretty smile, it's just a flow forEach launch collect emit loop
23 Views