How do you unsubscribe from a Firebase realtime listener?

Viewed 163

enter image description here

This is really confusing/frustrating.

I am trying to unsubscribe from a realtime listener on Cloud Firestore.

Both the official docs as well as the code base comments in the SDK say that the onSnapshot function should return an firebase.Unsubscribe function that I can call when I'm ready to unsubscribe.

Looking at the actual code though. The onSnapshot function clearly returns a () => Void

Does anyone know what's going on here?

Does calling the returned () => void function unsubscribe you from the listener?

Any help is much appreciated.... thanks!

1 Answers

Does calling the returned () => void function unsubscribe you from the listener?

Yes, that's exactly the case.

Related