2

I create a standard listener like this

private ValueEventListener aListener = new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {

        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    };

And attached to my Firebase databas

databaseRef.child(chatRoot)
                .orderByChild("some key")
                .limitToLast(12)
                .addValueEventListener(aListener );

If I now have 5-10 different listener I wanted a way to peek in and see how many there are attached. Lets say I want to do this to insure listener are on/off

Constantin Beer
  • 5,447
  • 6
  • 25
  • 43
Erik
  • 5,039
  • 10
  • 63
  • 119
  • Check out this answer, which suggests using a hashmap to keep track of listeners, where the key is the database reference and the value is the listener: https://stackoverflow.com/a/33782474/4816918 – Jeff Jun 02 '17 at 21:23
  • Thanks actually I am doing exactly that right now with hashmap. Just asking this question anyway to kind of shake the tree – Erik Jun 02 '17 at 21:26

0 Answers0