https://kotlinlang.org logo
Title
m

melatonina

06/05/2021, 4:09 PM
Is
flatMapLatest
supposed to work correctly with
StateFlow
? In the following code:
val locallyAvailableProjectIdsFlow = storageFlow.flatMapLatest {
    it?.projectEntityPackageStorage?.projectIdsFlow
        ?: emptyFlow<WatchState<List<ProjectId>>>().asStateFlow(WatchState.Idle())
}
storageFlow
and
projectIdsFlow
are `StateFlow`s, but
locallyAvailableProjectIdsFlow
is not being updated.
asStateFlow
is defined as:
private fun <T> Flow<T>.asStateFlow(initialValue: T) =
    stateIn(coroutineScope, SharingStarted.Eagerly, initialValue)
Am I doing anything wrong?
Yes, they work together. I made a semplified version of the same code and it works. There must be a problem somewhere.