-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vm.$on() from within components stores component state in vm but doesn't remove it when destroyed #3399
Comments
If the event is registered on an external bus, you need to tear it down in If this gets repetitive, you can write a mixin to automate this. |
What's the process for tearing it down? I haven't been able to find that in the docs. |
vm.$off |
You can refer to this:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm using 1.0.26.
After refactoring my project to replace $dispatch/$broadcast with an empty global Vue instance as a message bus using $on/$emit, I'm finding that if I call vm.$on() from the created() hook of a component, the component's entire state shows up in vm as vm._events.eventName[n].function scope.Closure._this.
Which is all well and good until a component gets destroyed, at which point the events it registered with vm.$on() seem to live forever and keep firing with the complete state it had just before it was destroyed.
Even if I were to add a 'deleted' flag to my components and use it to prevent them from doing anything, they're still setting in memory forever.
Is this a bug, or am I skipping a step somewhere in the component destruction process?
The text was updated successfully, but these errors were encountered: