Sha256: 8851760c31b15401de2093982bf088e4e36d0826a925ec29a0b7539e037f1c53
Contents?: true
Size: 1.06 KB
Versions: 46
Compression:
Stored size: 1.06 KB
Contents
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: -> @backbonify(@props) componentWillReceiveProps: (nextProps)-> @backbonify(nextProps) backbonify: (props)-> @__bb = [] for name of @backboneMap data = props[name] if data? && data? && !(data instanceof Backbone.Model || data instanceof Backbone.Collection) # Rewrite the prop as the correct Backbone model or collection. klass = @backboneMap[name] props[name] = new klass(data) # Save a reference so we wire up events. @__bb.push props[name] # Whenever there may be a change in the Backbone data, trigger a reconcile. componentDidMount: -> _.each @__bb, (model) => model.on 'all', @forceUpdate.bind(this, null), this # Clean up any dangling references when the component is destroyed. componentWillUnmount: -> _.each @__bb, (model) => model.off null, null, this
Version data entries
46 entries across 46 versions & 1 rubygems