From 71d49858f9c5e6e4e7ea86d137f0c8300456382e Mon Sep 17 00:00:00 2001 From: Thiago Colucci and Patrick Maia Date: Fri, 8 Aug 2014 17:02:23 -0300 Subject: adds ability to define behavior when a feature is toggled off --- web-ui/app/js/mixins/with_feature_toggle.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'web-ui') diff --git a/web-ui/app/js/mixins/with_feature_toggle.js b/web-ui/app/js/mixins/with_feature_toggle.js index 2b071e68..cf8d0d07 100644 --- a/web-ui/app/js/mixins/with_feature_toggle.js +++ b/web-ui/app/js/mixins/with_feature_toggle.js @@ -1,14 +1,17 @@ define(['features'], function(features) { - function withFeatureToggle(componentName) { + function withFeatureToggle(componentName, behaviorForFeatureOff) { return function() { - this.around('initialize', function(basicInitialize) { + this.around('initialize', _.bind(function(basicInitialize) { if(features.isEnabled(componentName)) { return basicInitialize(arguments[1], arguments[2]); } - }); + else if (behaviorForFeatureOff){ + behaviorForFeatureOff.bind(this).call(); + } + }, this)); }; } -- cgit v1.2.3