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);
 

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    65
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    65

Package Sidebar

Install

npm i listen-js

Weekly Downloads

25

Version

1.0.1

License

MIT

Last publish

Collaborators

  • npm