-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Description
Known issue in all blogs.
I have Fragment A and Fragment B, called Fragment B and inside this i have one api call and I am observing the Livedata. I got the response from API and its working fine. I navigateUp to Fragment A and come back again to Fragment B, again the last observer trigers. Even though am removing the observer and creating new.
Fragment B:
private val viewModel : MyViewModel by activityViewModels()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel .getData().removeObservers(viewLifecycleOwner)
viewModel .getData().observe(viewLifecycleOwner, Observer {
navController.navigateUp() // this calls again and again
})
}
Metadata
Metadata
Assignees
Labels
No labels