'use strict'
_ = require 'underscore'
Backbone = require 'backbone'
EventBroker = require 'chaplin/lib/event_broker'
Model = require 'chaplin/models/model'
utils = require 'chaplin/lib/utils''use strict'
_ = require 'underscore'
Backbone = require 'backbone'
EventBroker = require 'chaplin/lib/event_broker'
Model = require 'chaplin/models/model'
utils = require 'chaplin/lib/utils'Abstract class which extends the standard Backbone collection in order to add some functionality.
module.exports = class Collection extends Backbone.CollectionMixin an EventBroker.
_.extend @prototype, EventBrokerUse the Chaplin model per default, not Backbone.Model.
model: ModelSerializes collection.
serialize: ->
@map utils.serialize disposed: false
dispose: ->
return if @disposedFire an event to notify associated views.
@trigger 'dispose', thisEmpty the list silently, but do not dispose all models since they might be referenced elsewhere.
@reset [], silent: trueUnbind all global event handlers.
@unsubscribeAllEvents()Unbind all referenced handlers.
@stopListening()Remove all event handlers on this module.
@off()Remove model constructor reference, internal model lists and event handlers.
properties = [
'model',
'models', '_byId', '_byCid',
'_callbacks'
]
delete this[prop] for prop in propertiesFinished.
@disposed = trueYou’re frozen when your heart’s not open.
Object.freeze? this