I'm building some logic in my app that dynamically discards query onSnapshot listeners and creates new ones. I want to test that resources are been set free by the correct use of the unsubscribe function.
I don't have access to the unsubscribe reference to spy on it. I was wondering if there is a way to know how many active onSnapshot listeners are active, so I could expect the correct count on them.
I'm using the version 9 of the firebase web javascript sdk.
There's nothing built into the Firebase SDKs for counting the active Firestore listeners. If you need something like that, you'll have to build it yourself by increasing a counter when you attach a listener, and decreasing it when you remove a listener.