event-target-mixin
v1.0.4
Published
JavaScript W3C EventTarget mixin for custom objects.
Downloads
2
Maintainers
Readme
event-target-mixin.js
W3C EventTarget mixin for custom objects
Usage
import EventTarget from 'event-target-mixin';
// Applying EventTarget to custom object
let Car = () => {
EventTarget.call(this);
this.start = () => {
this.dispatchEvent(new Event('started'));
};
};
// Using events
let car = new Car();
car.addEventListener('started', (event) => { // setting onStarted should work too
if (event.type === 'started')
alert('vroom vroom!');
});
car.start();
Build
$ npm install
$ npm run build
License
MIT
forked from ShareIt-project/EventTarget.js and mrdoob/eventdispatcher.js
see LICENSE file