Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/doesdev/singleton-dom-events
One event to rule... err that one thing. Making scope complex DOM events safe since 2016
https://github.com/doesdev/singleton-dom-events
Last synced: about 20 hours ago
JSON representation
One event to rule... err that one thing. Making scope complex DOM events safe since 2016
- Host: GitHub
- URL: https://github.com/doesdev/singleton-dom-events
- Owner: doesdev
- Created: 2016-09-30T19:11:54.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T16:24:43.000Z (almost 2 years ago)
- Last Synced: 2024-11-15T22:13:08.324Z (4 days ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# singleton-dom-events [![npm version](https://badge.fury.io/js/singleton-dom-events.svg)](http://badge.fury.io/js/singleton-dom-events) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)
DOM event manager that strictly allows one event per identifier.
It simply stores the elements and callbacks based on the passed identifier
and ensures they are removed before (re-)adding them.## install
`npm i singleton-dom-events --save`## api / function signature
- **identifier** *(String [unique identifier for event] - required)*
- **element** *(DOM element - required)*
- **eventName** *(String - required)*
- **callback** *(Function - required)*
- **useCapture** *(Boolean - optional)*## usage
Example
```javascript
const setEvent = require('singleton-dom-events')let myCb = => console.log('yay')
setEvent('window-resize', window, 'resize', myCb)
setEvent.remove('window-resize')```