Skip to content

vm.$on() from within components stores component state in vm but doesn't remove it when destroyed #3399

@groovy9

Description

@groovy9

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions