1.1.2 • Published 9 years ago

voltrevo-event-emitter v1.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

voltrevo-event-emitter

NPM version Build Status Dependency Status Coverage Status Code Climate

My utopian vision for simple eventing.

An event emitter that probably does everything you actually need in only 70 lines of code.

Install

$ npm install --save voltrevo-event-emitter

Usage

'use strict';

var EventEmitter = require('voltrevo-event-emitter');

var ee = EventEmitter();

// events are asynchronous

ee.emit('foo', 'bar');

ee.on('foo', function(value) {
  console.log(value); // bar
});

// .once works as usual

ee.emit('boom');
ee.emit('boom');

ee.once('boom', function() {
  console.log('boom'); // only one boom
});

// .on and .once return Collection handles, which have .remove

ee.emit('unicorn');

var listener = ee.on('unicorn', function() {
  console.log('A wild unicorn appeared!'); // this never happens
});

listener.remove();

License

MIT © Andrew Morris

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago