Skip to content

Commit d4ad044

Browse files
committed
README
1 parent 4b3e29d commit d4ad044

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
# EventListener
22
Modern event listener for efficient applications based on the [subscribe-publish](https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8) pattern.
33

4+
**EventListener** is less than 900 bytes when minified, but packs a surprising amount of power.
5+
46
# NPM
57
```
68
npm install event-listener.js
79
```
810

911
# Package Features
10-
* *EventListener* is ES6+ sourced with TypeScript definitions;
11-
* *EventListener* comes with ES6, ES5 and ESM packaging, all in `/dist` folder;
12-
* *EventListener* makes use of the native [Map](https://caniuse.com/mdn-javascript_builtins_map) to subscribe/register or unsubscribe/remove listeners, which is perfect since we need to make sure the exact listeners are added/removed;
13-
* *EventListener* allows you to register multiple listeners for the same target, even of the same type, but always uses a single `globalListener` to call them all at once when event is triggered;
14-
* *EventListener* "should" be able to manage event options, especially `once`, meaning that when the option is `true`, the listener is automatically un-subscribed and detached from target;
15-
* *EventListener* will unsubscribe and detach listeners with the same options used when attached, which means you can "lazy" remove listeners on the fly.
12+
* **EventListener** is ES6+ sourced with TypeScript definitions;
13+
* **EventListener** comes with ES6, ES5 and ESM packaging, all in `/dist` folder;
14+
* **EventListener** makes use of the native [Map](https://caniuse.com/mdn-javascript_builtins_map) to subscribe/register or unsubscribe/remove listeners, which is perfect since we need to make sure the exact listeners are added/removed;
15+
* **EventListener** allows you to register multiple listeners for the same target, even of the same type, but always uses a single `globalListener` to call them all at once when event is triggered;
16+
* **EventListener** "should" be able to manage event options, especially `once`, meaning that when the option is `true`, the listener is automatically un-subscribed and detached from target;
17+
* **EventListener** will unsubscribe and detach listeners with the same options used when attached, which means you can "lazy" remove listeners on the fly.
1618

1719
# Use
1820

@@ -63,9 +65,14 @@ Map(1) {
6365
if (documentClickListeners && documentClickListeners.has(handleMyClick)) {
6466
// do something about it
6567
}
68+
69+
// get listener options
70+
const myListenerOptions = documentClickListeners && documentClickListeners.get(handleMyClick));
71+
72+
// returns { once: true }
6673
```
6774

68-
For advanced use, check out the [demo](./demo/index.html), showcasing the *EventListener* usage with a demo component.
75+
For advanced use, check out the [demo](./demo/index.html), showcasing the **EventListener** usage with a demo component.
6976

7077
# License
71-
*EventListener* is released under the [MIT License](https://github.com/thednp/event-listener.js/blob/main/LICENSE).
78+
**EventListener** is released under the [MIT License](https://github.com/thednp/event-listener.js/blob/main/LICENSE).

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
"build-esm": "rollup --environment FORMAT:esm,MIN:false -c",
4040
"build-esm-min": "rollup --environment FORMAT:esm,MIN:true -c"
4141
},
42-
"dependencies": {},
4342
"devDependencies": {
4443
"@rollup/plugin-buble": "^0.21.3",
4544
"@rollup/plugin-json": "^4.1.0",

0 commit comments

Comments
 (0)