The Viewmodel is not destroyed even when the oncleared is called

Viewed 117

there is a Nested graph inside them two fragments (A,B) with 3 viewmodels 1 sharedviewmodel and 2 individual the individual viewmodel is not getting destroyed even when the findNavController().popBackStack() is called which inturn calls onCleared of viewmodel

this is initialization inside one of the fragment B'sVm = ViewModelProvider(this).get(B'sViewModel::class.java)

There is a recyclerview inside the B's fragment which take the list from viewmodel(through binding) (after network call) then called findNavController().popBackStack() to go to A's Fragment(the onCleared of viewmodel is called ) Then navigated to Fragment B . the previous list is still there .

Fragment A->Fragment B(list the data) -> Fragemnt A-> Fragment B(previous list still there )

0 Answers
Related