You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
blockvote/node_modules/yaeti
STRIV1 f8251e172e
1
1 year ago
..
lib 1 1 year ago
.jscsrc 1 1 year ago
.jshintrc 1 1 year ago
.npmignore 1 1 year ago
LICENSE 1 1 year ago
README.md 1 1 year ago
gulpfile.js 1 1 year ago
index.js 1 1 year ago
package.json 1 1 year ago

README.md

yaeti

Yet Another EventTarget Implementation.

The library exposes both the EventTarget interface and the Event interface.

Installation

$ npm install yaeti --save

Usage

var yaeti = require('yaeti');


// Custom class we want to make an EventTarget.
function Foo() {
    // Make Foo an EventTarget.
    yaeti.EventTarget.call(this);
}

// Create an instance.
var foo = new Foo();

function listener1() {
    console.log('listener1');
}

function listener2() {
    console.log('listener2');
}
 
foo.addEventListener('bar', listener1);
foo.addEventListener('bar', listener2);
foo.removeEventListener('bar', listener1);

var event = new yaeti.Event('bar');

foo.dispatchEvent(event);


// Output:
// => "listener2"

API

yaeti.EventTarget interface

Implementation of the EventTarget interface.

  • Make a custom class inherit from EventTarget:
function Foo() {
    yaeti.EventTarget.call(this);
}
  • Make an existing object an EventTarget:
yaeti.EventTarget.call(obj);

The interface implements the addEventListener, removeEventListener and dispatchEvent methods as defined by the W3C.

listeners read-only property

Returns an object whose keys are configured event types (String) and whose values are an array of listeners (functions) for those event types.

yaeti.Event interface

Implementation of the Event interface.

NOTE: Just useful in Node (the browser already exposes the native Event interface).

var event = new yaeti.Event('bar');

Author

Iñaki Baz Castillo

License

MIT