Skip to content

Instantly share code, notes, and snippets.

@hwclass
Created July 2, 2015 09:00
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 hwclass/3cab5a6b4cc906d6969a to your computer and use it in GitHub Desktop.
Save hwclass/3cab5a6b4cc906d6969a to your computer and use it in GitHub Desktop.
Design Patterns : Singleton Pattern
/**
* @fileoverview The base initialization method
* @author hwclass
*/
/**
* base.js
* This file is used to make some creating initialization routines
*/
'use strict';
//-----------------------------------------------------------
// Public
//-----------------------------------------------------------
/** @type {Object} */
var Config = require(‘models/Config’);
/** @type {Object} */
var configInstance = new Config();
/** @type {Object} */
var config = configInstance.getConfig();
/** @type {null} */
configInstance = null;
$(‘.error).html(config.messages.errors.default);
/**
* @fileoverview The base object to get configuration
* @author hwclass
*/
/**
* models/Config.js
* This object is used to fetch needed configuration parameters
*/
'use strict';
//-----------------------------------------------------------
// Public
//-----------------------------------------------------------
/**
* Config object
* @noparam
*/
module.exports = (function () {
return function () {
var config = {
urls : {
tabs : {
address : '/#address',
payment : '/#payment'
}
},
messages : {
errors : {
no_address_selected : 'Please, select an address to go next',
no_cards_used : 'You need to choose a credit card to pay',
default : 'An error occured. Please try again later'
}
}
/**
* getConfig method
* @noparam
*/
var getConfig = function () {
return config;
}
return {
getConfig : getConfig
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment