node package manager

tmitter

tMitter

minimalistic emitter-system in Javascript, learn maximal 4 method, that you might already know from backbone.events or Emitter.js. The design decision, to allow only a single parameter to trigger, will help you to write more reusable code.

This code, is not begging to get used from you in production, but maybe it will help you to understand how event-systems work.

var b = {};
tMitter(b);
b.on('update',function(){console.log('b has updated');});
b.trigger('update');
// output: b has updated 
 

Description

The tMitter-Method is like an extend of Backbone. it takes an Object and that will get the properties to handle the events.

After an object became an tMitter using "tMitter(theObject)", you can start to listen using "on" or begin to "trigger" events.

the fourth method, that might be interesting is "off". This can be used to remove an event-listener.