I’m using Firebase as my main database for a project. I have some subscriptions to Snapshot listeners that I use to get realtime information out of the database. However I need to unsubscribe them when the user leaves the page. How can I do that?
Whenever I used Firebase in other projects, there were functions like onDestroy() or useEffect() but I haven’t been successful in finding something similar with Velo.
Below is an example of what I mean:
unsubscribe = onSnapshot(doc(db, "cities", "SF"), (document) => {
// Does something
});
onDestroy() {
unsubscribe();
}