Sha256: 7f6eddf6936f2a0d382b58638173206171daad2662eeac368db3101bdc1eb024
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
class ModelType extends Lanes.Models.State constructor: -> super @records = {} session: id: 'string' records: 'object' subscribe: (model)-> channel = "/#{model.api_path}/#{model.id}" Lanes.Vendor.MessageBus.subscribe(channel,(changes)-> model.addChangeSet(changes) ) channel add: (model)-> if (config = @records[model.id]) config.model = model else @records[model.id] = { model: model, channel: this.subscribe(model) } remove: (model)-> if ( config = @records[model.id] ) Lanes.Vendor.MessageBus.unsubscribe( config.channel ) delete @records[model.id] class ModelTypesCollection extends Lanes.Models.BasicCollection constructor: -> super model: ModelType forModel: (model)-> models = this.get(model.api_path) || this.add(id: model.api_path) Lanes.Models.PubSub = { types: new ModelTypesCollection forModel: (model)-> add: (model)-> return unless model.isPersistent() @types.forModel(model).add(model) remove: (model)-> return unless model && model.isPersistent() @types.forModel(model).remove(model) instanceFor: ( model_klass, id )-> @types.get(model_klass.prototype.api_path)?.records[id]?.model clear: -> @types = new ModelTypesCollection initialize: -> Lanes.Vendor.MessageBus.start() Lanes.Vendor.MessageBus.callbackInterval = 500 }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lanes-0.1.2 | client/lanes/models/PubSub.coffee |
lanes-0.1.0 | client/lanes/models/PubSub.coffee |