Skip to content

component.destroyed #935

Closed
Closed
@Rich-Harris

Description

@Rich-Harris

Just ran into a case where it would be useful to know, within a component method, whether or not the component still exists (the method runs in a setTimeout, which could fire after the component has been destroyed).

With knowledge of the internals there are various ways to do this, and you could also do it by setting a custom property inside a destroy event handler, but it might be nice if there was a standard, documented way to do it:

export default {
  methods: {
    thingThatRunsPeriodically() {
      if (this.destroyed) return;
      doSomeStuff();
    }
  }
};

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