Sha256: eb3fe51b9e8d7ead45437a82036095545eb63a7cc756d82c84f64b052eadb7fc
Contents?: true
Size: 1.4 KB
Versions: 46
Compression:
Stored size: 1.4 KB
Contents
#= require ./BackboneStore Rev.registerComponent 'ModelPrepper', mixins: [Rev.Mixins.BackboneStore] getInitialState: -> state = model: null error: null componentWillMount: -> @fetch() get: -> @store.get @props.collection, @props.model fetch: -> @store.fetch @props.collection, @props.model, @onFetchComplete onFetchComplete: -> if model = @get() @setState model: model else @setState error: true render: -> if @state.model? @success() else if @state.error? @error() else @wait() success: -> if @props.onSuccess? then @props.onSuccess @state.model, this else @props.children error: -> if @props.onError? then @props.onError(@retry) else null wait: -> if @props.onWait? then @props.onWait() else null retry: -> @setState error: null # bindModelChanges: (model) -> # # console.log "bind", model # model.on 'add change remove', @forceUpdate.bind(this, null), this # # unbindModelChanges: (model) -> # # console.log "unbind", model # model.off null, null, this # # componentWillMount: -> # @bindModelChanges @state.model if @state.model? # # componentWillUpdate: (props, state) -> # if state.model? and not @state.model? # @bindModelChanges state.model # # componentWillUnmount: -> # @unbindModelChanges @state.model if @state.model?
Version data entries
46 entries across 46 versions & 1 rubygems