@cfware/add-event-listener
v1.0.0
Published
Calls owner.addEventListener and returns a function to remove the listener
Downloads
21
Readme
@cfware/add-event-listener
Calls owner.addEventListener and returns a function to remove the listener.
Usage
import addEventListener from '@cfware/add-event-listener';
class MyElement extends HTMLElement {
connectedCallback() {
this._cleanupFn = addEventListener(window, 'click', () => console.log('click'));
}
disconnectedCallback() {
this._cleanupFn();
}
}