Hello, I’m developing for Android and am switching to Coucbase Lite.
As I understand after adding a change listener for a document or starting a live query in an Activity/Fragment one should remove the change listener and stop the live query some time later to prevent memory leaks and not process unnecessary callbacks. Am I right?
If yes, what is the best place to call Document.removeChangeListener()
or LiveQuery.stop()
in Activity and Fragment? I can think of Activity.onPause()
or it would be better to do it in Activity.onDestroy()
?
You should remove the listener whenever you don’t need the notifications anymore.