@cfware/add-event-listener

1.0.0 • Public • Published

@cfware/add-event-listener NPM Version

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

Dependencies (0)

    Dev Dependencies (5)

    Package Sidebar

    Install

    npm i @cfware/add-event-listener

    Weekly Downloads

    8

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    4.31 kB

    Total Files

    5

    Last publish

    Collaborators

    • coreyfarrell