Sha256: 072a017291bdbfdbff55975084f3faa48afe846a5fee53f13807d6a7fe781a47

Contents?: true

Size: 1.36 KB

Versions: 29

Compression:

Stored size: 1.36 KB

Contents

//= require ./mixins/mix_spec_into_component

/* This optional extension re-enables the React mixin system for plain JS
 * classes, e.g. ES6 classes, Backbone classes, ES3 module pattern classes
 * You require the extension like `//= require revelry/extensions/mixins` and
 * then you just use appComponent and revComponent like normal.
 * Internally, this works by wrapping the appComponent and revComponent methods
 * in a function closure which actually does the mixing in, since React punts.
 */
(function(Rev) {

  function mixinListForObject(object) {
    var mixinList = object.mixins || [];
    mixinList.push(Rev.Mixins.Core);
    return _.uniq(mixinList);
  }

  function forEachMixin(object, fn) {
    var mixin, i, l;
    var mixinList = mixinListForObject(object);
    l = mixinList.length;
    for(i = 0; i < l; i++) {
      mixin = mixinList[i];
      fn(mixin);
    }
  }

  function decorateComponentMethod(componentMethod) {
    return function(name, object) {
      var componentClass = (componentMethod.bind(Rev))(name, object);
      if(typeof object === 'function') {
        // ES6 class
        forEachMixin(object, function(mixin){
          Rev.__mixSpecIntoComponent(componentClass, mixin);
        });
      }
    }
  }

  Rev.appComponent = decorateComponentMethod(Rev.appComponent);
  Rev.registerComponent = decorateComponentMethod(Rev.registerComponent);

})(Rev);

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
revelry_core-0.1.12.6 app/assets/javascripts/revelry/extensions/mixins.js
revelry_core-0.1.12.5 app/assets/javascripts/revelry/extensions/mixins.js
revelry_core-0.1.12.4 app/assets/javascripts/revelry/extensions/mixins.js
revelry_core-0.1.12.3 app/assets/javascripts/revelry/extensions/mixins.js
revelry_core-0.1.12.2 app/assets/javascripts/revelry/extensions/mixins.js
revelry_core-0.1.12.0 app/assets/javascripts/revelry/extensions/mixins.js
revelry_core-0.1.11.6 app/assets/javascripts/revelry/extensions/mixins.js
revelry_core-0.1.11.5 app/assets/javascripts/revelry/extensions/mixins.js
revelry_core-0.1.11.2 app/assets/javascripts/revelry/extensions/mixins.js
revelry_core-0.1.11.1 app/assets/javascripts/revelry/extensions/mixins.js
revelry_core-0.1.11.0 app/assets/javascripts/revelry/extensions/mixins.js
revelry_core-0.1.10.7 app/assets/javascripts/revelry/extensions/mixins.js
revelry_core-0.1.10.6 app/assets/javascripts/revelry/extensions/mixins.js
revelry_core-0.1.10.5 app/assets/javascripts/revelry/extensions/mixins.js
revelry_core-0.1.10.4 app/assets/javascripts/revelry/extensions/mixins.js
revelry_core-0.1.10.3 app/assets/javascripts/revelry/extensions/mixins.js
revelry_core-0.1.10.2 app/assets/javascripts/revelry/extensions/mixins.js
revelry_core-0.1.10.1 app/assets/javascripts/revelry/extensions/mixins.js
revelry_core-0.1.10.0 app/assets/javascripts/revelry/extensions/mixins.js
revelry_core-0.1.9.2 app/assets/javascripts/revelry/extensions/mixins.js