2.0.2 • Published 7 years ago

emitter-js v2.0.2

Weekly downloads
5
License
Apache-2.0
Repository
github
Last release
7 years ago

Emitter

A modern event emitter implementation.

Emitter.js is an event emitter based on the nodejs EventEmitter but utilizing some of the new features in ECMAScript 6.

Installation

Git

git clone https://github.com/jeffrose/emitter emitter

NPM

npm install emitter-js

Bower

bower install emitter-js

Documentation

Usage

Emitter.js provides both an ES5 and ES6 version as part of the distribution.

Additional examples can be found in the API docs and unit tests.

ECMAScript 6

// Depending on the scenario the /index may not be necessary
import Emitter from '../node_modules/emitter-js/dist/emitter';

let greeter = new Emitter();

greeter.on( 'hello', ( name ) => console.log( `Hello, ${ name }!` ) );
greeter.emit( 'hello', 'World' );
// Hello, World!

ECMAScript 5

var Emitter = require( 'emitter-js' ),

    greeter = new Emitter();

greeter.on( 'hello', function( name ){
    console.log( 'Hello, ' + name + '!' ) );
} );
greeter.emit( 'hello', 'World' );
// Hello, World!

Differences from EventEmitter

Emitter.js...

  • Lacks domain support.
  • Has a succint API with no backward compatibility aliases, e.g. clear() instead of removeAllListeners().
  • Has namespaced lifecycle event types, e.g. :off instead of removeListener.
  • Does not use console.log().
2.0.2

7 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.3.0

11 years ago

1.2.1

11 years ago

1.2.0

11 years ago

1.1.2

11 years ago

1.1.1

11 years ago

1.1.0

11 years ago

1.0.0

11 years ago