Events Mixin Module
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
.gitignore
LICENSE
README.md
bower.json
events_mixin.js
events_proto.js
gulpfile.js
package.json

README.md

eventsjs

Events Module

Usage

As a mixin with a revealing module
  
  function MyModule () { Events().call(this); }
  var myModule = new MyModule();
  
  myModule.on('name', function () { 
    console.log('name event!');
  }, this);
  
  myModule.trigger('name'); // name event!
  myModule.off('name');
  myModule.trigger('name'); // 
  
  // creating a shareable global events object
  var globalEvents = Events().call({});
  
As a inheritable module with the prototype version

inheritance using inherit_js

  
  function MyModule () { Events.prototype.constructor.call(this); }
  inherit(Events, MyModule);
  var myModule = new MyModule();
  
  myModule.on('name', function () { 
    console.log('name event!');
  }, this);
  
  myModule.trigger('name'); // name event!
  myModule.off('name');
  myModule.trigger('name'); // 
  
  // creating a shareable global events object
  var globalEvents = new Events();