melatonina
06/05/2021, 4:09 PMflatMapLatest
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?