| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A quite basic implementation of Core-Sandbox-Module pattern. API is based on talks and slides by N. Zakas[1] and Eric Shepherd[2]. This implementation heavily relies upon a correct use of the revealing module pattern [3], and upon the publish/subscribe pattern. Base library (jQuery is used here) is lightly abstracted from sandbox and modules; some main functions are exposed like sandbox.DOM.find(selector) which is equivalent to $().
Aim of the pattern is providing a loosely coupled architecture for JS applications.
Architecture components are:
Base library Provides cross-browser functionalities. JQuery is used here.
Core object Is responsible for:
Sandbox Sandbox is responsible for:
Module(s) Each module is defined by a Module Creator function, knows only about its Sandbox and is subject to these rules:
Basically is all about:
var MyModule = function (sandbox){
return {
init: function(){
//Module initialization
},
destroy: function(){
//Module destruction
}
// put your code here, and use your sandbox as needed...
};
}
You can only have one unique name per module.
Core.register("myModule", MyModule);
Core.startAll();
[1] Nicholas Zakas' Core-Sandbox-Module
[2] Building a JavaScript Module Framework at Gilt
[3] Christian Heilmann’s Revealing-module pattern
| Back | FazBrowse Home | New Git URL |