Issue
According to Firestore documentation, we can simply add and remove snapshotListener automatically just by passing the instance of Activity to the snapshotListener. But the snapshotListener can only be removed onStop. onStop()
is not guaranteed to be called all the time. Should I add/remove my snapshotListener onResume/onPause instead?
Solution
If you're not satisfied with when the automatic cancelation of snapshot listeners happen when you pass an Activity
when registering them, you can instead manage the listener lifecycle yourself. There is nothing wrong with this, and is in fact what I usually do.
There is no singular correct answer here. It all depends on your preferences and the requirements of your app.
Answered By - Frank van Puffelen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.