diff options
Diffstat (limited to 'src/global.js')
-rw-r--r-- | src/global.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/global.js b/src/global.js new file mode 100644 index 0000000..c837b44 --- /dev/null +++ b/src/global.js @@ -0,0 +1,31 @@ +//Global storage section +//global object stores data which is dependent on different modules +//to release an object from memory specify global.destroy("variablename") +define(['lodash'], function(_) { + + + var global = { + destroy: function(objectName) { + global[objectName] = null; + }, + destroyAll: function() { + var _keysExceptMethods = _.omitBy(global, function(value, key) { + return ( + _.eq(key, 'destroy') || + _.eq(key, 'destroyAll') || + _.eq(key, 'find') + ); + }); + + _.forEach(_keysExceptMethods, function(value, key) { + global[key] = null; + }) + }, + find: function(key) { + var pickedVar = _.pick(global, key); + return pickedVar; + } + } + + return global; +}); |