Created
December 20, 2016 14:38
-
-
Save Buslowicz/4c71441102607dc7e4ac8eca059989a9 to your computer and use it in GitHub Desktop.
Destroyable web components mixin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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