Skip to content

Instantly share code, notes, and snippets.

@DavidCarcamo
Created July 2, 2013 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidCarcamo/5911084 to your computer and use it in GitHub Desktop.
Save DavidCarcamo/5911084 to your computer and use it in GitHub Desktop.
Singleton
/**
* Creates a single instance of ClassName.
* @author Author Name
*
* @constructor
* @this {ClassName}
* @param {object} The settings for this class.
* @version v.0.0.1
*/
// JSLint
/*global
VarName1:false,
varName2:false
*/
var ClassName = function(){
var constructor = function(settings){
// SETUP
var _this = this;
var defaults;
// merge settings
defaults = {};
settings = _.extend(settings || {}, defaults);
// DOM cache
var elms = {};
// Private property
var template = '<div class="domClass"></div>';
// METHODS
/**
* A public privilaged method.
*
* @this {ClassName}
*/
_this.publicPrivilaged = function(){
};
/**
* A private method.
*
* @this {ClassName}
*/
var private = function(){
};
// Overwrite so only one instance can ever be created
constructor = function(){ return _this };
};
return constructor;
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment