@taufik-nurrohman/event

1.0.1 • Public • Published

Event Utility

Utility of native event listener implementation.

Usage

CommonJS

const {onEvent} = require('@taufik-nurrohman/event');

onEvent('resize', window, e => {
    console.log([
        window.innerHeight,
        window.innerWidth
    ]);
});

ECMAScript

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.

let readyEvent = event('ready');

events

List of custom events cache created by event.

console.log(events);

fireEvent(event, node, options = {}, cache = false)

onEvent('DOMContentLoaded', document, event => {
    fireEvent('ready', document);
});

fireEvents(events, node, options = {}, cache = false)

offEvent(event, node, then)

offEvent('ready', document, onDocumentReady);

offEventDefault(event)

offEventImmediatePropagation(event)

offEventPropagation(event)

offEvents(events, node, then)

onEvent(event, node, then, options = false)

function onDocumentReady() {
    console.log('Document is ready!');
}

onEvent('ready', document, onDocumentReady);

onEvents(events, node, then, options = false)

/@taufik-nurrohman/event/

    Package Sidebar

    Install

    npm i @taufik-nurrohman/event

    Weekly Downloads

    119

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    5.67 kB

    Total Files

    5

    Last publish

    Collaborators

    • taufik-nurrohman