Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove all listeners in Firebase java

I know that the documentation says "// In Java, each listener must be removed explicitly.". But there is a problem.

I deploy my app - add a listener (save pointer). But when I re-deploy my app the listener is still there, but I cannot remove it because I don´t have a pointer for it.

So is any way how to remove all listeners? (without server restart)

like image 388
Casero Avatar asked Feb 03 '14 22:02

Casero


People also ask

How do I get rid of Firebase listener?

Detach listeners Callbacks are removed by calling the removeEventListener() method on your Firebase database reference. If a listener has been added multiple times to a data location, it is called multiple times for each event, and you must detach it the same number of times to remove it completely.

What is off () method in firebase?

Detach listeners Callbacks are removed by calling the off() method on your Firebase database reference. You can remove a single listener by passing it as a parameter to off() .

How do I get rid of listener on Android?

You just use removeListener(this).

How do I remove a child event listener?

Calling removeEventListener() removes the listener from that location. It will stop firing events after it has completed them for data it's already received. If you're still getting calls to the listener, something else is going on that is unfortunately impossible to say from the code you shared.


1 Answers

This still applies until now, as you cannot remove all listeners at once.

To check for any updates you can see this link: https://firebase.google.com/support/release-notes/android

Currently, you can do it inside onDestroy()

protected void onDestroy(){
super.onDestroy();
yourdatabasereference.removeEventListener(Listenernamehere);
}
like image 83
Peter Haddad Avatar answered Oct 10 '22 13:10

Peter Haddad