@vanruesc/eventdispatcher
v0.1.10
Published
A supportive base class that enables any object to dispatch events to registered listeners.
Downloads
4
Maintainers
Readme
EventDispatcher
A supportive base class that enables any object to dispatch events to registered listeners.
Installation
This module can be installed from npm.
$ npm install @vanruesc/eventdispatcher
Usage
import EventDispatcher from "@vanruesc/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
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 Rüschen
Licensed under the Zlib license.