Why doesn't my UiState(stateflow object) update after updating in the viewmodel?

Advertisements I update the uiState in the model by the updateSelectedCategory(category = selectedCategory) function, I checked through the logs int the viewmodel, everything is fine, it is updated. But, when I check this in the WhehereToGoApp compose function, the parameter uiState.currentPlacesList is not updated, why? I think I’m somehow not collecting the state correctly, but… Read More Why doesn't my UiState(stateflow object) update after updating in the viewmodel?

Kotlin StateFlow multiple subscriptions after returning from another Fragment

Advertisements I’m trying to implement StateFlow in my app with MVVM architecture between ViewModel and Fragment. In ViewModel: … private val _eventDataState = MutableStateFlow<EventDataState>(EventDataState.Loading) val eventDataState: StateFlow<EventDataState> = _eventDataState … In Fragment: … override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) … lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.STARTED) { viewModel.eventDataState.collect { eventDataState -> when (eventDataState) { is… Read More Kotlin StateFlow multiple subscriptions after returning from another Fragment

flowWithLifecycle(lifecycle, Lifecycle.State.STARTED) doesn't stop flows while App is in background

Advertisements I’m trying to observe the result of the View Collection and upstream flows stopped. But viewModel.testFlow is still collecting while the App is in the background. Why can’t I observe the collection is stopped? Am I observing something wrong? ViewModel: val testFlow = flow<Int> { for (i in 1..100) { delay(1000) Timber.e("testFlow: EMIT =… Read More flowWithLifecycle(lifecycle, Lifecycle.State.STARTED) doesn't stop flows while App is in background