hitman
It's all about fulfilling contracts.
Happy path (works just like an EventEmitter):
var Hitman = require('hitman').Hitman;
var emitter = new Hitman(['1', '2']);
emitter.on('1', function() {
console.log('hello world');
});
emitter.emit('1');
Wrapping an external EventEmitter:
var Hitman = require('hitman').Hitman,
EventEmitter = require('events').EventEmitter;
var ext_emitter = new EventEmitter(),
emitter = new Hitman(['1', '2'], { emitter: ext_emitter });
emitter.on('1', function() {
console.log('hello world');
});
emitter.emit('1');
Both of the following examples will throw an error:
var Hitman = require('hitman').Hitman;
var emitter = new Hitman(['1', '2']);
emitter.on('3', function() {
console.log('hello world');
});
var Hitman = require('hitman').Hitman;
var emitter = new Hitman(['1', '2']);
emitter.emit('3');