Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Lifecycle Observer is not removed in step_4 #5

Closed
Zhuinden opened this issue May 20, 2017 · 4 comments
Closed

Lifecycle Observer is not removed in step_4 #5

Zhuinden opened this issue May 20, 2017 · 4 comments

Comments

@Zhuinden
Copy link

Here, there is addObserver() call, but there is no removeObserver() call for onDestroy. Is this intentional?

@JoseAlcerreca
Copy link
Contributor

Yes, that's the whole point of the new lifecycle-aware components, no need to unsubscribe/remove observers.

@Zhuinden
Copy link
Author

Cool! Thanks :D

@AndroidDeveloperLB
Copy link

Can you please update the docs about it?
As a precaution, I always remove the observer when not needed (even asked about it here), even if I use it just for onDestroy event.
It's especially true for ON_DESTROY , that we don't need to call removeObserver for it, so maybe add a note there:

https://developer.android.com/reference/android/arch/lifecycle/Lifecycle.Event#ON_DESTROY

?

@trevorhackman
Copy link

In the event that onDestroy which is not guaranteed to be called, is not called, does the observer ever get removed?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants