You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
})
}
The text was updated successfully, but these errors were encountered:
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
})
}
The text was updated successfully, but these errors were encountered: