last day (15 days later) » 

10:37 AM
0
Q: How to update data with SharedFlow in Android

Dr.KeyOkIn my application I want update data with SharedFlow and my application architecture is MVI . I write below code, but just update one of data! I have 2 spinners and this spinners data fill in viewmodel. ViewModel code : class MyViewModel @Inject constructor(private val repository: DetailReposit...

 
@Skizo-ozᴉʞS thanks my friend, I change it and again result is such as previous !
 
Can you make your funcitons suspend and then use emit with viewModelScope.launch{ _uiState.emit(...) on both methods? fetchingCategoriesList and fetchingPrioritiesList? if it doesn't work, try to add a delay in between viewModel.handleIntent(MyIntent.CategoriesList) and viewModel.handleIntent(MyIntent.priorityList) to check if it's that the problem
 
@Skizo-ozᴉʞS , in viewModel : private suspend fun fetchingCategoriesList() = viewModelScope.launch { val data = mutableListOf(Car, Animal, Color, Food) _state.emit(DetailState.CategoriesData(data)) } private suspend fun fetchingPrioritiesList() = viewModelScope.launch { val data = mutableListOf(Low, Normal, High) _state.emit(DetailState.PriorityData(data)) }
fragment is : lifecycleScope.launch { viewModel.handleIntent(DetailIntent.CategoriesList) viewModel.handleIntent(DetailIntent.PriorityList) but result like previous !
 
Do you have this project public on github or somewhere else? So I can check it?
 
@Skizo-ozᴉʞS thanks my friend. do you help free time for connect to my system with Anydesk?
 
10:37 AM
can't do this, I do prefer you to upload it to github or somewhere so I can check and see the problem if possible :)
 
@Skizo-ozᴉʞS , please wait for upload it . thanks
@Skizo-ozᴉʞS my files is here : mediafire.com/file/ryp24b1h2bedexw/note.zip/file please help me
@Skizo-ozᴉʞS , I added delay it's fix. my code is: private suspend fun fetchingPrioritiesList() = viewModelScope.launch { val data = mutableListOf(HIGH, NORMAL, LOW) delay(50) _state.emit(DetailState.PriorityData(data)) } but I want to know this way is good? is this good practice or not?
 
Hi please could you add it in your github?
https://medium.com/code-yoga/how-to-link-android-studio-with-github-312037a13b99
This is how to do it
The delay works because the emit you do is too fast and the collect only gets the second item since it's almost at the same time the emit
That's why if you do a small delay it gives time to the collector to get the state
 
11:12 AM
Hi
sorry, project is for compony and i cant upload this into github
 

last day (15 days later) »