@zayesh/eventdispatcher

0.1.8 • Public • Published

EventDispatcher

Build status Windows Build status GitHub version npm version Dependencies

A supportive base class that enables any object to dispatch events to registered listeners.

Installation

This module can be installed from npm.

$ npm install @zayesh/eventdispatcher

Usage

import EventDispatcher from "@zayesh/eventdispatcher";

function Something() {

	EventDispatcher.call(this);

}

Something.prototype = Object.create(EventDispatcher.prototype);
Something.prototype.constructor = Something;

// If you want Something to be a true sub-class of another class,
// you can just use the apply method for multi-inheritance:
EventDispatcher.prototype.apply(Something.prototype);
var sth = new Something();

sth.addEventListener("boom", function() {

	alert("pow!");

});

sth.dispatchEvent({type: "boom"});

Documentation

API

Contributing

Maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

License

Copyright (c) 2015 Raoul van Rueschen
Licensed under the Zlib license.

Package Sidebar

Install

npm i @zayesh/eventdispatcher

Weekly Downloads

1

Version

0.1.8

License

Zlib

Last publish

Collaborators

  • zayesh