event-target-mixin

1.0.4 • Public • Published

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

Links

W3C DOM4 specification
DOM Living Standard specification

Dependents (0)

Package Sidebar

Install

npm i event-target-mixin

Weekly Downloads

1

Version

1.0.4

License

MIT

Last publish

Collaborators

  • petzen