Sha256: 25948c17f348cc719d7d3a02ed0b6ecf898e832501b211e85c98adabe692244a

Contents?: true

Size: 1.61 KB

Versions: 12

Compression:

Stored size: 1.61 KB

Contents

{
I"
metadata:ET{I"modules;T{I"imports;T[I"exports;T{I"
exported;T[I"specifiers;T[I"usedHelpers;T[I"ignored;TFI"	code;TI"½'use strict';

Rev.registerMixin('BackboneProps', {
  // Component should contain a map of prop names to Backbone classes, like:
  //
  // backboneMap = {
  //   users: User.Collection,
  // }

  // Set up our Backbone instance objects.
  componentWillMount: function componentWillMount() {
    this.backbonify(this.props);
  },

  componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
    this.backbonify(nextProps);
  },

  backbonify: function backbonify(props) {
    var _this = this;

    this.__bb = [];

    _.each(this.backboneMap, function (klass, name) {
      var data = props[name];

      if (data != null && !(data instanceof Backbone.Model || data instanceof Backbone.Collection)) {
        // Rewrite the prop as the correct Backbone model or collection.
        props[name] = new klass(data);
      }

      // Save a reference so we can wire up events.
      _this.__bb.push(props[name]);
    });
  },

  // Whenever there may be a change in the Backbone data, trigger a reconcile.
  componentDidMount: function componentDidMount() {
    var _this2 = this;

    _.each(this.__bb, function (model) {
      model.on('all', _this2.forceUpdate.bind(_this2, null), _this2);
    });
  },

  // Clean up any dangling references when the component is destroyed.
  componentWillUnmount: function componentWillUnmount() {
    var _this3 = this;

    _.each(this.__bb, function (model) {
      model.off(null, null, _this3);
    });
  }

});;TI"ast;T0I"map;T0

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
revelry_core-0.1.24.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/XO/XOpA7laprCxxkpy5Dx2V0yH-SZAqV-OpYpHQN9v6gpY.cache
revelry_core-0.1.23.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/XO/XOpA7laprCxxkpy5Dx2V0yH-SZAqV-OpYpHQN9v6gpY.cache
revelry_core-0.1.22.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/XO/XOpA7laprCxxkpy5Dx2V0yH-SZAqV-OpYpHQN9v6gpY.cache
revelry_core-0.1.21.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/XO/XOpA7laprCxxkpy5Dx2V0yH-SZAqV-OpYpHQN9v6gpY.cache
revelry_core-0.1.20.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/XO/XOpA7laprCxxkpy5Dx2V0yH-SZAqV-OpYpHQN9v6gpY.cache
revelry_core-0.1.19.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/XO/XOpA7laprCxxkpy5Dx2V0yH-SZAqV-OpYpHQN9v6gpY.cache
revelry_core-0.1.18.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/XO/XOpA7laprCxxkpy5Dx2V0yH-SZAqV-OpYpHQN9v6gpY.cache
revelry_core-0.1.17.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/XO/XOpA7laprCxxkpy5Dx2V0yH-SZAqV-OpYpHQN9v6gpY.cache
revelry_core-0.1.16.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/XO/XOpA7laprCxxkpy5Dx2V0yH-SZAqV-OpYpHQN9v6gpY.cache
revelry_core-0.1.15.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/XO/XOpA7laprCxxkpy5Dx2V0yH-SZAqV-OpYpHQN9v6gpY.cache
revelry_core-0.1.14.0 spec/dummy/tmp/cache/assets/test/sprockets/v3.0/3ohRDsxxiluLFRAPlxLB2wg0fQVpY9UbGG9-z1t9dxA.cache
revelry_core-0.1.13.0 spec/dummy/tmp/cache/assets/test/sprockets/v3.0/3ohRDsxxiluLFRAPlxLB2wg0fQVpY9UbGG9-z1t9dxA.cache