Skip to content
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

Component ngOnDestroy check suggestion #265

Closed
kenger opened this issue Mar 7, 2019 · 1 comment
Closed

Component ngOnDestroy check suggestion #265

kenger opened this issue Mar 7, 2019 · 1 comment

Comments

@kenger
Copy link

kenger commented Mar 7, 2019

Hi,

its possibile to change

  ngOnDestroy() {
    if (this.instance) {
      setTimeout(() => {
        this.instance.removeAllListeners();
        CKEDITOR.instances[this.instance.name].destroy();
        this.instance.destroy();
        this.instance = null;
      });
    }
  }

into

  ngOnDestroy() {
    if (this.instance) {
      setTimeout(() => {
        if (this.instance) {
          this.instance.removeAllListeners();
          CKEDITOR.instances[this.instance.name].destroy();
          this.instance.destroy();
          this.instance = null;
        }
      });
    }
  }

?

I'm destroying the instances myself in a wrapper component but now the code die because this.instance in the original component is null. Never check before a setTimeout without a recheck inside the setTimeout :)

@kzimny
Copy link
Collaborator

kzimny commented Mar 13, 2019

Your suggestion looks good. Thank you. Would you make a pull request?

@kzimny kzimny closed this as completed in 875d319 May 5, 2019
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

2 participants