0👍
as you know that previous listener is not detached after you leave the previous chat and create a new listener for a new collection. so it still listening, i assume that you using options api, you can create a data "id" that will used for getting collection of message from props, and "listener" data for listening variable
attach listener data to snapshot in mounted function, after that create a watcher that watching data id changed or not, if changed, detach the listener variable and attach new listener with new id from props in watcher
- [Vuejs]-VUE: How to configure dynamical router URLs
- [Vuejs]-AbortController does not cancel axios.get
Source:stackexchange.com