Aaron Waller
09/16/2022, 3:40 PMprivate val _userStateFlow: MutableStateFlow<UserStateModel?> = MutableStateFlow(UserStateModel())
val userStateFlow: StateFlow<UserStateModel?> = _userStateFlow
in my MainViewModel I’m collecting this state and i’m passing the user state down the hierarchy.
Before implementing nested navigation everything got updated accordingly but since I implemented nested navigation the change get’s lost somewhere inside my navigationGraph.
Anyone else faced this problem?Aaron Waller
09/16/2022, 3:44 PMprivate val _mainUserState: MutableState<UserStateModel?> = mutableStateOf(null)
val mainUserState: State<UserStateModel?> = _mainUserState
init {
viewModelScope.launch {
authRepository.getUserState().collect() {
_mainUserState.value = it
}
}
}
My MainActivity:
val userState by mainViewModel.mainUserState
and from there I’m passing this userState down the hierarchyRick Regan
09/16/2022, 3:45 PMAaron Waller
09/18/2022, 3:12 PMRick Regan
09/18/2022, 11:27 PM