Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cfware/add-event-listener
Calls owner.addEventListener and returns a function to remove the listener
https://github.com/cfware/add-event-listener
Last synced: 29 days ago
JSON representation
Calls owner.addEventListener and returns a function to remove the listener
- Host: GitHub
- URL: https://github.com/cfware/add-event-listener
- Owner: cfware
- License: mit
- Created: 2019-03-23T00:30:09.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-10-15T15:10:55.000Z (about 1 year ago)
- Last Synced: 2024-10-28T12:38:37.670Z (about 2 months ago)
- Language: JavaScript
- Size: 30.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @cfware/add-event-listener [![NPM Version][npm-image]][npm-url]
Calls owner.addEventListener and returns a function to remove the listener.
## Usage
```js
import addEventListener from '@cfware/add-event-listener';class MyElement extends HTMLElement {
connectedCallback() {
this._cleanupFn = addEventListener(window, 'click', () => console.log('click'));
}disconnectedCallback() {
this._cleanupFn();
}
}
```[npm-image]: https://img.shields.io/npm/v/@cfware/add-event-listener.svg
[npm-url]: https://npmjs.org/package/@cfware/add-event-listener