Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/taufik-nurrohman/event
Utility of native event listener implementation.
https://github.com/taufik-nurrohman/event
event helper native node utility
Last synced: 17 days ago
JSON representation
Utility of native event listener implementation.
- Host: GitHub
- URL: https://github.com/taufik-nurrohman/event
- Owner: taufik-nurrohman
- License: mit
- Created: 2020-11-19T02:04:01.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-06-11T23:31:40.000Z (over 1 year ago)
- Last Synced: 2024-09-25T15:14:42.633Z (about 1 month ago)
- Topics: event, helper, native, node, utility
- Language: JavaScript
- Homepage:
- Size: 19.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Event Utility
=============Utility of native event listener implementation.
Usage
-----### CommonJS
~~~ js
const {onEvent} = require('@taufik-nurrohman/event');onEvent('resize', window, e => {
console.log([
window.innerHeight,
window.innerWidth
]);
});
~~~### ECMAScript
~~~ js
import {onEvent} from '@taufik-nurrohman/event';onEvent('resize', window, e => {
console.log([
window.innerHeight,
window.innerWidth
]);
});
~~~Methods
-------### event(name, options = {}, cache = false)
Create custom events with unique name.
~~~ js
let readyEvent = event('ready');
~~~### events
List of custom events cache created by `event`.
~~~ js
console.log(events);
~~~### fireEvent(event, node, options = {}, cache = false)
~~~ js
onEvent('DOMContentLoaded', document, event => {
fireEvent('ready', document);
});
~~~### fireEvents(events, node, options = {}, cache = false)
### offEvent(event, node, then)
~~~ js
offEvent('ready', document, onDocumentReady);
~~~### offEventDefault(event)
### offEventImmediatePropagation(event)
### offEventPropagation(event)
### offEvents(events, node, then)
### onEvent(event, node, then, options = false)
~~~ js
function onDocumentReady() {
console.log('Document is ready!');
}onEvent('ready', document, onDocumentReady);
~~~### onEvents(events, node, then, options = false)