Skip to content

Instantly share code, notes, and snippets.

@Offirmo
Last active December 2, 2018 07:54
Show Gist options
  • Save Offirmo/550be6f9aad8ef1b08c61a795a757a97 to your computer and use it in GitHub Desktop.
Save Offirmo/550be6f9aad8ef1b08c61a795a757a97 to your computer and use it in GitHub Desktop.
[global browser singleton] #JavaScript #browser #growth #frontend
var global_module_instance;
Object.defineProperty(window, 'global_ng_module', {
enumerable: true, // why not ?
set: function() {
throw new Error('You can’t assign window.global_module !');
},
get: function() {
if(global_module_instance) return global_module_instance; // already OK
global_module_instance = angular.module('global_ng_module', [
'ui.bootstrap'
]);
return global_module_instance;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment