Last active
December 2, 2018 07:54
-
-
Save Offirmo/550be6f9aad8ef1b08c61a795a757a97 to your computer and use it in GitHub Desktop.
[global browser singleton] #JavaScript #browser #growth #frontend
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
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