listen-js

1.0.1 • Public • Published

ListenJS

A small, lightweight library that adds addEventListener(), removeEventListener(), and dispatchEvent() methods to any object.

The event listener methods follow the EventTarget (https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) API, also allowing this library to serve as a polyfill.

Usage

var obj = {};
 
Listen.createTarget(obj);
 
// listen to the "wee" event
obj.addEventListener('wee', function () {
    // wee was trigger!
});
 
// trigger the event
obj.dispatchEvent('wee');
 
Listen.destroyTarget(obj);
 

/listen-js/

    Package Sidebar

    Install

    npm i listen-js

    Weekly Downloads

    34

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • npm