I found an issue in vue-router which triggers me a lot. Always when I switch between my routes, a new instance of the component is created. Further the old instances are not
Always when I switch between my routes, a new instance of the component is created.
That's expected. you can keep instanes alive and re-use them with the
component, but that's usually not necessary and if so, requires special attention to re-initiate all local state of re-used components where necesseray.
Creating a fresh instance is much cleaner and therefore the default behaviour.
Further the old instances are not deleted and are running in background!
That's not expected. Previous instances are destroyed.
setInterval(() => {console.log('Instance ' + this._uid + ' of Foo is running')}, 500);
Well, since this intervall callback contains a reference to the component instance, it can't be garbage collected by the browser, So you are keeping them alive, not Vue.
Without that intervall, I woudl expect the instance to be garbage collected after the router destroyed them.