Sha256: eca7f72fe6c6cc8cd6531c7bb7dfe28a72f18c75a90763307d2f55a68096ce8a
Contents?: true
Size: 949 Bytes
Versions: 2
Compression:
Stored size: 949 Bytes
Contents
class Lanes.Views.ModelObserver extends Lanes.Data.State model_events: {} constructor: (@view, @keypath='model')-> super @view.on( "change:#{@keypath}", this.rebindModel, this ) @view.on( "remove", this.teardown, this ) this.rebindModel() getModel: -> @cached_model ||= Lanes.getPath(@keypath, @view) unBindModel: (model)-> for event, fn of @model_events model.off(event, this[fn], this ) bindModel: (model)-> for event, fn of @model_events 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lanes-0.0.8 | client/lanes/views/ModelObserver.coffee |
lanes-0.0.5 | client/lanes/views/ModelObserver.coffee |