Skip to content

Instantly share code, notes, and snippets.

@Buslowicz
Created December 20, 2016 14:38
Show Gist options
  • Save Buslowicz/4c71441102607dc7e4ac8eca059989a9 to your computer and use it in GitHub Desktop.
Save Buslowicz/4c71441102607dc7e4ac8eca059989a9 to your computer and use it in GitHub Desktop.
Destroyable web components mixin
const Destroyable = (superclass, destroyTimeout) => class extends superclass {
detachedCallback() {this.__destroying = setTimeout(() => { if (!this.isConnected && this.destroyedCallback) this.destroyedCallback() }, destroyTimeout)},
attachedCallback() {clearTimeout(this.__destroying)}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment