Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is ValueEventListener keep listening if the reference it was listening to is being removed?

I have this code:

FirebaseDatabase.reference.child(path).addValueEventListener(object : ValueEventListener 
{
        override fun onDataChange(snapshot: DataSnapshot) {
            /**LOGIC**/
        }
        override fun onCancelled(error: DatabaseError) {

        }
    })

While path removed from database.

Is it still listening?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

A listener always listens to changes regardless of whether or not there is any data at the given location. It will keep listening until the program terminates or you remove the listener. If there was no data present at the time of registration, then new data appears, then it will trigger the listener callbacks.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading