@jsantell/event-target

1.1.3 • Public • Published

event-target

Build Status

Simple implementation of EventTarget. Hosted on npm as @jsantell/event-target. ES6-ified for inclusion via module bundler.

Installation

$ npm install --save @jsantell/event-target

Usage

import EventTarget from '@jsantell/event-target';

class ChunkReader extends EventTarget {
  constructor(data) {
    this.data = data;

    requestAnimationFrame(() => this.read(data));
  }

  read() {
    for (let i = 0; i < this.data.length; i += 4) {
      this.dispatchEvent('chunk', this.data.substr(i, 4));
    }
    this.dispatchEvent('end');
  }
}

const reader = new ChunkReader('hello world!');
reader.addEventListener('chunk', c => console.log('chunk!'));
reader.addEventListener('end', () => console.log('end!'));

Build

$ npm run build

Publish

$ npm run version

License

MIT License, Copyright © 2018 Jordan Santell

Readme

Keywords

Package Sidebar

Install

npm i @jsantell/event-target

Weekly Downloads

0

Version

1.1.3

License

MIT

Unpacked Size

14.9 kB

Total Files

9

Last publish

Collaborators

  • jsantell