summaryrefslogtreecommitdiff
path: root/web-ui/app/js/mixins/with_feature_toggle.js
blob: cf8d0d077b0c1f72206e9d8418edd686e967c33c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
define(['features'],
  function(features) {

    function withFeatureToggle(componentName, behaviorForFeatureOff) {
      return function() {

        this.around('initialize', _.bind(function(basicInitialize) {
          if(features.isEnabled(componentName)) {
            return basicInitialize(arguments[1], arguments[2]);
          }
          else if (behaviorForFeatureOff){
            behaviorForFeatureOff.bind(this).call();
          }
        }, this));
      };
    }

    return withFeatureToggle;

});