• 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
  • cellMixin.js

  • ¶
    (function(root, factory) {
      if (typeof define === 'function' && define.amd) {
        define([], factory);
      } else if (typeof exports === 'object') {
        module.exports = factory();
      } else {
        root.Torso = root.Torso || {};
        root.Torso.Mixins = root.Torso.Mixins || {};
        root.Torso.Mixins.cell = factory();
      }
    }(this, function() {
      'use strict';
      /**
       * An non-persistable object that can listen to and emit events like a models.
       *
       * @mixin cellMixin
       * @author kent.willis@vecna.com
       *
       * @see <a href="../annotated/modules/mixins/cellMixin.html">cellMixin Annotated Source</a>
       */
      return /** @lends cellMixin */ {
        /**
         * Whether a cell can pass as a model or not.
         * If true, the cell will not fail is persisted functions are invoked
         * If false, the cell will throw exceptions if persisted function are invoked
         * @property {boolean} isModelCompatible
         * @default false
         */
        isModelCompatible: false,
    
        /**
         * Override and disable the save function
         */
        save: function() {
          if (!this.isModelCompatible) {
            throw 'Cell does not have save';
          }
        },
    
        /**
         * Override and disable the fetch function
         */
        fetch: function() {
          if (!this.isModelCompatible) {
            throw 'Cell does not have fetch';
          }
        },
    
        /**
         * Override and disable the sync function
         */
        sync: function() {
          if (!this.isModelCompatible) {
            throw 'Cell does not have sync';
          }
        },
    
        /**
         * Override and disable the url
         */
        url: function() {
          if (!this.isModelCompatible) {
            throw 'Cell does not have url';
          }
        }
      };
    }));