Assume I have a page called pageA
where I am monitoring changes to a firebase document.
export default {
mounted() {
this.$f7ready(() => {
this.userChanges();
})
},
methods: {
userChanges() {
Firebase.database().ref('users/1').on('value', (resp) => {
console.log('user data has changed');
});
}
}
}
Next, I navigate to another page called pageB
using
this..$f7.views.current.router.navigate('/pageB/')
When I modify the data in the /users/1
firebase route while on pageB
, the message user data has changed
appears in the console, even though I am on a different page.
Is there a way to prevent this behavior? Perhaps by unloading the page somehow?
I attempted to stop the listener before leaving pageA
using Firebase.off(), but that caused some other issues.