# good-listener

> A more versatile way of adding & removing event listeners

Latest version **1.2.2** (published 2017-02-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install good-listener
pnpm add good-listener
yarn add good-listener
bun add good-listener
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2017-02-28 |
| First published | 2015-10-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 143 |
| Maintainers | zenorocha |
| Keywords | event, listener |

## Links

- npm: https://www.npmjs.com/package/good-listener
- Repository: https://github.com/zenorocha/good-listener
- Homepage: https://github.com/zenorocha/good-listener#readme
- Issues: https://github.com/zenorocha/good-listener/issues
- npm.io page: https://npm.io/package/good-listener

## Dependencies (1)

- [delegate](https://npm.io/package/delegate.md) ^3.1.2

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 1.2.2 (latest) — 2017-02-28
- 1.2.1 — 2016-12-12
- 1.2.0 — 2016-10-23
- 1.1.8 — 2016-09-25
- 1.1.7 — 2016-02-11
- 1.1.6 — 2016-02-02
- 1.1.5 — 2016-02-02
- 1.1.4 — 2015-11-13
- 1.1.3 — 2015-11-13
- 1.1.2 — 2015-10-26
- 1.1.1 — 2015-10-26
- 1.1.0 — 2015-10-26
- 1.0.0 — 2015-10-25

## README

# good-listener

[![Build Status](http://img.shields.io/travis/zenorocha/good-listener/master.svg?style=flat)](https://travis-ci.org/zenorocha/good-listener)

> A more versatile way of adding & removing event listeners.

![good listener](https://cloud.githubusercontent.com/assets/398893/10718224/dfc25f6c-7b2a-11e5-9d3d-75b35e8603c8.jpg)

## Install

You can get it on npm.

```
npm install good-listener --save
```

Or bower, too.

```
bower install good-listener --save
```

If you're not into package management, just [download a ZIP](https://github.com/zenorocha/good-listener/archive/master.zip) file.

## Setup

###### Node (Browserify)

```js
var listen = require('good-listener');
```

###### Browser (Standalone)

```html
<script src="dist/good-listener.js"></script>
```

## Usage

### Add an event listener

By passing a string selector [(see full demo)](https://github.com/zenorocha/good-listener/blob/master/demo/selector.html).

```js
listen('.btn', 'click', function(e) {
    console.log(e);
});
```

Or by passing a HTML element [(see full demo)](https://github.com/zenorocha/good-listener/blob/master/demo/node.html).

```js
var logo = document.getElementById('logo');

listen(logo, 'click', function(e) {
    console.log(e);
});
```

Or by passing a list of HTML elements [(see full demo)](https://github.com/zenorocha/good-listener/blob/master/demo/nodelist.html).

```js
var anchors = document.querySelectorAll('a');

listen(anchors, 'click', function(e) {
    console.log(e);
});
```

### Remove an event listener

By calling the `destroy` function that returned from previous operation [(see full demo)](https://github.com/zenorocha/good-listener/blob/master/demo/destroy.html).

```js
var listener = listen('.btn', 'click', function(e) {
    console.log(e);
});

listener.destroy();
```

## Browser Support

| <img src="https://clipboardjs.com/assets/images/chrome.png" width="48px" height="48px" alt="Chrome logo"> | <img src="https://clipboardjs.com/assets/images/edge.png" width="48px" height="48px" alt="Edge logo"> | <img src="https://clipboardjs.com/assets/images/firefox.png" width="48px" height="48px" alt="Firefox logo"> | <img src="https://clipboardjs.com/assets/images/ie.png" width="48px" height="48px" alt="Internet Explorer logo"> | <img src="https://clipboardjs.com/assets/images/opera.png" width="48px" height="48px" alt="Opera logo"> | <img src="https://clipboardjs.com/assets/images/safari.png" width="48px" height="48px" alt="Safari logo"> |
|:---:|:---:|:---:|:---:|:---:|:---:|
| Latest ✔ | Latest ✔ | Latest ✔ | 9+ ✔ | Latest ✔ | Latest ✔ |

## License

[MIT License](http://zenorocha.mit-license.org/) © Zeno Rocha

---
_Source: https://npm.io/package/good-listener · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
