Draccoz
12/20/2016 - 2:38 PM

Destroyable web components mixin

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)}
};