Recomposition doesn't trigger even after using mutablestatelistof in Jetpack compose While Updating the Values

91 Views Asked by At

I have this state var testFeedList : MutableList<Feed>? = mutableStateListOf() Inside the viewModel

 override fun onGetFeedList() {
                viewModelScope.launch(Dispatchers.Main) {
                    repository.getFeedListByCategory().collect { feedData ->
//                        state.feedList.value = feedData.data
                        state.testFeedList = feedData.data
                        setState(state)
                        Logger.log(
                            "GetFeedResult Inside VM TESTFEED: " + GsonUtils.toString(
                                state.testFeedList
                            )
                        )
                        Logger.log(
                            "FEEDDATA Inside VM: " + GsonUtils.toString(
                                feedData.data
                            )
                        )

                    }
                }
            }

I have logged and data is coming. The Problem here is I have two Screens, In the first i Show the list of feed and in second i do CRUD operations. When i update the some of the data in the list and return back to the First Screen(List of Feed Screen), I don't see changes, When i close the app and see again i see the changes, Why isn't the recomposition occuring? Recomposition occurs when i add the item but don't when edit it?

Also val uiState by vm.uiStateUI.collectAsState() this is how i called the state and uiState.testFeedList as List<Feed> this is how i called for the list.

0

There are 0 best solutions below