diff options
author | Patrick Maia <patrickjourdanmaia@gmail.com> | 2014-08-07 16:01:04 -0300 |
---|---|---|
committer | Patrick Maia <patrickjourdanmaia@gmail.com> | 2014-08-08 13:44:43 -0300 |
commit | b30c4434e50c4e3ac128cf04ce4935ca6c660037 (patch) | |
tree | 694c57df36e002e6fff6091812aeafae298e7a35 /web-ui/app/js/mixins | |
parent | 77b12bda3df10710daf7c441512146170523f003 (diff) |
adds with_feature_toggle mixin
Diffstat (limited to 'web-ui/app/js/mixins')
-rw-r--r-- | web-ui/app/js/mixins/with_feature_toggle.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/web-ui/app/js/mixins/with_feature_toggle.js b/web-ui/app/js/mixins/with_feature_toggle.js new file mode 100644 index 00000000..3a484388 --- /dev/null +++ b/web-ui/app/js/mixins/with_feature_toggle.js @@ -0,0 +1,20 @@ +define(['lib/features'], + function(features) { + + function withFeatureToggle(componentName) { + return function() { + + var defaultToggle = {enabled: true}; + + this.around('initialize', function(basicInitialize) { + var featureToggle = features[componentName] || defaultToggle; + if(featureToggle.enabled) { + basicInitialize(arguments[1], arguments[2]); + } + }); + }; + } + + return withFeatureToggle; + +}); |