futureeventemitter

=======================

npm install futureeventemitter
8 downloads in the last month

FutureEventEmitter

=======================

Installation

npm install FutureEventEmitter

Usage

var emitter = new FutureEventEmitter();

emitter.emitAndListen('eventName', 42);

emitter.on('eventName', function(answer) {
    console.log('Called event with: ' + answer);
});

Outputs:

Called event with: 42

Using emitAndListen, the event will be called whether the listener is created before and after it.

This replaces the traditional pattern with the standard EventEmitter which would look like this:

var emitter = new EventEmitter();

emitter.emit('eventName', 42);
emitter.on('newListener', function(eventName, listener) {
    if (eventName == 'eventName') {
        listener(42);
    }
});

emitter.on('eventName', function(answer) {
    console.log('Called event with: ' + answer);
});
npm loves you