Skip to content

component.destroyed #935

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

Closed
Rich-Harris opened this issue Nov 22, 2017 · 2 comments
Closed

component.destroyed #935

Rich-Harris opened this issue Nov 22, 2017 · 2 comments

Comments

@Rich-Harris
Copy link
Member

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();
    }
  }
};
@aubergene
Copy link

Descartes would say - "I am destroyed, therefore I am not"

@ekhaled
Copy link
Contributor

ekhaled commented Jan 3, 2018

@Rich-Harris this was never merged into master, is that an oversight?

Would help in eliminating some console warnings in svelte-hot-loader

sacrosanctic pushed a commit to sacrosanctic/svelte that referenced this issue Dec 24, 2024
fix cursor position on state changes - fixes sveltejs#935
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants