Sha256: 8c9b5cc9525c0ec565fddc55283c01281463fd476581c51d7d3402ad4492797a
Contents?: true
Size: 950 Bytes
Versions: 14
Compression:
Stored size: 950 Bytes
Contents
class Lanes.Views.ModelObserver extends Lanes.Models.State modelEvents: {} constructor: (@view, @keypath='model')-> super @view.on( "change:#{@keypath}", this.rebindModel, this ) @view.on( "remove", this.teardown, this ) this.rebindModel() getModel: -> @cached_model ||= Lanes.u.getPath(@keypath, @view) unBindModel: (model)-> for event, fn of @modelEvents model.off(event, this[fn], this ) bindModel: (model)-> for event, fn of @modelEvents model.on(event, this[fn], this ) rebindModel: -> @cached_model=null old_model = @view.previous(@keypath) new_model = this.getModel() return if old_model == new_model this.unBindModel( old_model ) if old_model this.bindModel( new_model ) if new_model teardown: -> this.unBindModel( model ) if model = this.getModel()
Version data entries
14 entries across 14 versions & 1 rubygems