1.0.1 • Published 9 years ago

listen-js v1.0.1

Weekly downloads
6
License
MIT
Repository
github
Last release
9 years ago

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