• Jump To … +
    modules/Behavior.js modules/Cell.js modules/Collection.js modules/Events.js modules/FormModel.js modules/FormView.js modules/ListView.js modules/Model.js modules/NestedCell.js modules/NestedModel.js modules/Router.js modules/ServiceCell.js modules/View.js modules/behaviors/DataBehavior.js modules/configure.js modules/handlebarsUtils.js modules/history.js modules/mixins/cacheMixin.js modules/mixins/cellMixin.js modules/mixins/loadingMixin.js modules/mixins/modelMixin.js modules/mixins/pollingMixin.js modules/registry.js modules/stickitUtils.js modules/templateRenderer.js modules/torso.js modules/validation.js
  • Collection.js

  • ¶
    /**
     * The backbone Collection reference
     * @external Backbone-Collection
     * @extends external:Backbone-Events
     * @see {@link http://backbonejs.org/#Collection|Backbone.Collection}
     */
    (function(root, factory) {
      if (typeof define === 'function' && define.amd) {
        define(['underscore', 'backbone', './mixins/pollingMixin', './mixins/cacheMixin', './mixins/loadingMixin'], factory);
      } else if (typeof exports === 'object') {
        module.exports = factory(require('underscore'), require('backbone'), require('./mixins/pollingMixin'), require('./mixins/cacheMixin'), require('./mixins/loadingMixin'));
      } else {
        root.Torso = root.Torso || {};
        root.Torso.Collection = factory(root._, root.Backbone, root.Torso.Mixins.polling, root.Torso.Mixins.cache, root.Torso.Mixins.loading);
      }
    }(this, function(_, Backbone, pollingMixin, cacheMixin, loadingMixin) {
      'use strict';
    
      /**
       * Generic Collection
       *
       * @class Collection
       * @extends {external:Backbone-Collection}
       * @mixes pollingMixin
       * @mixes loadingMixin
       * @mixes cacheMixin
       *
       * @author kent.willis@vecna.com
       *
       * @see <a href="../annotated/modules/Collection.html">Collection Annotated Source</a>
       */
      var Collection = Backbone.Collection.extend(/** @lends Collection# */{
          /**
           * The default filter.  Always returns itself.
           * @returns {Collection} a new instance of this collection
           */
          filterDefault: function() {
            return this.constructor(this);
          },
    
          /**
           * Will abolish all listeners and events that are hooked
           * to this collection.
           */
          dispose: function() {
            this.unbind();
            this.off();
            this.stopListening();
            this.stopPolling();
            if (this.isRequester) {
              this.requesterDispose();
            }
          }
      });
      _.extend(Collection.prototype, pollingMixin);
      Collection = Collection.extend(loadingMixin(Collection));
      Collection = Collection.extend(cacheMixin(Collection));
    
      return Collection;
    }));