evandroeisinger / modules.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

modules.js

define:

var moduleConstructor = function(data) {}
var modulePrototype = {};

modules.define('ModuleName', moduleConstructor, modulePrototype);

require:

var ModuleName = modules.require('ModuleName');
var moduleName = new ModuleName();

__subscribe:

// listen to a single event
moduleName.__subscribe('eventName', function callback(data) {});

// asign to multiple events
moduleName.__subscribe(['eventName', 'otherEventName'], function callback(data) {});

// also avaiable on constructor
var moduleConstructor = function() {
  this.__subscribe('eventName', function(){});
};

// and prototype context
var modulePrototype = {
  method: function() {
    this.__subscribe('eventName', function(){});
  }
};

__emmit:

// emmit a single event
moduleName.__emmit('eventName', {});

// also avaiable on constructor
var moduleConstructor = function() {
  this.__emmit('eventName', {});
};

// and prototype context
var modulePrototype = {
  method: function() {
    this.__emmit('eventName', {});
  }
};

About


Languages

Language:JavaScript 77.5%Language:HTML 22.5%