Sha256: 66c1bf5b9331f44f6c529b70d00e179cdcb091b8a52d88154a39f6b494735534

Contents?: true

Size: 565 Bytes

Versions: 2

Compression:

Stored size: 565 Bytes

Contents

Luca.concerns.StateModel =
  __initializer: ()->
    return unless @stateful is true
    return if @state? and not Luca.isBackboneModel(@state)
    
    @state = new Backbone.Model(@defaultState || {})

    @set ||= ()=> @state.set.apply(@state, arguments)
    @get ||= ()=> @state.get.apply(@state, arguments)  

    @state.on "change", (state)=>
      @trigger "state:change", state
      previousValues = state.previousAttributes()
      for changed, value in state.changedAttributes
        @trigger "state:change:#{ changed }", value, state.previous(changed)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
luca-0.9.76 src/concerns/state_model.coffee
luca-0.9.7 src/concerns/state_model.coffee