Created
June 4, 2012 22:54
-
-
Save parhammmm/2871333 to your computer and use it in GitHub Desktop.
Namespace example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Creating a namespace | |
var chat = { | |
// Create this closure to contain the cached modules | |
module: function() { | |
// Internal module cache. | |
var modules = {}; | |
// Create a new module reference scaffold or load an | |
// existing module. | |
return function(name) { | |
// If this module has already been created, return it. | |
if (modules[name]) { | |
return modules[name]; | |
} | |
// Create a module and save it under this name | |
return modules[name] = { Views: {} }; | |
}; | |
}() | |
}; | |
//Defining a module in the namespace | |
(function(Friend) { | |
})(chat.module("friend")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment