As I know, each attached listener in Firebase Realtime Database must be removed with a call to removeEventListener()
. Suppose I attached a listener to a node inside a coroutine, and then later if I cancel the coroutine, then my app would stop listening to the database. For eg:
viewModelScope.launch {
Firebase.database.reference.child("users").addValueEventListener(usersListener) //usersListener is a ValueEventListener
}
In that case, does listener gets removed? Or there also I should explicitly remove listener? What happens if I don't remove the listeners I attached? How long do they stay there?