Where to unsubscribe from listeners

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();
}

You have to install the firebase NPM package.
Velo: Working with npm Packages | Help Center | Wix.com

You misunderstood the question. Firebase works for me. I’m unsure how to unsubscribe a Snapshot Listener in a Velo project.