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

leandro

01/25/2021, 4:06 PM
Is there an operator to go from
List<Flow<A>>
to
Flow<List<A>>
? I’m currently applying the following:
Copy code
.flatMapLatest { items: List<Flow<A>> ->
  combineTransform(items) {
    emit(it.toList())
  }
}
but am wondering if this is common enough and/or is handled in a better way with a different operator.
w

wasyl

01/25/2021, 4:32 PM
Maybe just
combine(items) { it.toList() }
? I don’t know any simpler method
☝️ 1
p

Paul Woitaschek

01/25/2021, 6:13 PM
Beware: if your list is empty there is no emission!
👍 1
We wrote a lint check that forbids the combine iterable function and have a custom flow that emits an empty list
This one did hit us pretty badly.
l

leandro

01/26/2021, 9:52 AM
thanks 😊
3 Views