diff options
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; + +}); |