I have this code with stateIn, my questions are: 1...
# compose
a
I have this code with stateIn, my questions are: 1. Am I using it correctly? 1. Is it better to do this instead of collecting the flow from ViewModel? 2. I have read we shouldn't use methods with statIn, what can I do if I need to pass parameters? any example? Repository: override val appLanguageStream: Flow<String> = dataStore.data.map { preferences -> val preferencesKey = stringPreferencesKey(Constants.APP_LANGUAGE) preferences[preferencesKey] ?: Constants.DEFAULT_LANGUAGE } ViewModel: val appLanguageStream: StateFlow<Resource<String>> = settingsRepository.appLanguageStream.asResource().stateIn( scope = viewModelScope, started = SharingStarted.WhileSubscribed(5_000), Resource.Success(Constants.DEFAULT_LANGUAGE) ) Screen: val appLanguageStream by viewModel.appLanguageStream.collectAsStateWithLifecycle() LaunchedEffect(key1 = appLanguageStream){ // update ViewModel uiState }