@vanruesc/eventdispatcher

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

Usage no npm install needed!

<script type="module">
  import vanruescEventdispatcher from 'https://cdn.skypack.dev/@vanruesc/eventdispatcher';
</script>

README

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 @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

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 RĂ¼schen
Licensed under the Zlib license.