Join Slack
Powered by
What's the best way to flatten a `Flow<Flow<...
# coroutines
j
julian
07/14/2020, 6:36 PM
What's the best way to flatten a
Flow<Flow<T>>
to
Flow<T>
?
j
Javier
07/14/2020, 6:46 PM
What is the usecase of that? You have
emitAll
to emit a flow without having to collect + emit
z
Zach Klippenstein (he/him) [MOD]
07/14/2020, 7:05 PM
There are some operators for this:
flattenConcat
–
https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/flatten-concat.html
flattenMerge
–
https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/flatten-merge.html
transformLatest
–
https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/transform-latest.html
(use with
emitAll
like
@Javier
said)
😍 1
j
julian
07/14/2020, 7:46 PM
Thanks
@Javier
@Zach Klippenstein (he/him) [MOD]
!
8
Views
Open in Slack
Previous
Next