Home

Awesome

raix:eventemitter

Isomorphic api for EventEmitter on server and browser, should work like Node.js EventEmitter on both client and server.

note: this package is flagged as deprecated and maintained for package-version support. if you need an isomorphic event listener then look out for npm packages like eventlistener3 or nano events.

Overview:

Wrapper apis node js like:

Wrapper apis jQuery like:

Tests are covered and will be extended as issues demand.

Usage

Creating EventEmitter object

Meteor.isClient() {
    Event = new EventEmitter();
}

Emitting event

Event.emit('customEvent', {
    data: bar
});

Listening the event (at a template for instance)

var listener;
Template.example.created = function() {
    listener = function(bar) {
        console.log('Listening custom event', bar);
    };
    Event.on('customEvent', listener);
}

Template.example.destroyed = function() {
    Event.removeListener('customEvent', listener);
}

Kind regards RaiX