Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / src / data / Batch.js
index 51971b5..218aa98 100644 (file)
@@ -1,73 +1,82 @@
+/*
+
+This file is part of Ext JS 4
+
+Copyright (c) 2011 Sencha Inc
+
+Contact:  http://www.sencha.com/contact
+
+GNU General Public License Usage
+This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
+
+If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
+
+*/
 /**
  * @author Ed Spencer
  * @class Ext.data.Batch
- * 
+ *
  * <p>Provides a mechanism to run one or more {@link Ext.data.Operation operations} in a given order. Fires the 'operationcomplete' event
  * after the completion of each Operation, and the 'complete' event when all Operations have been successfully executed. Fires an 'exception'
  * event if any of the Operations encounter an exception.</p>
- * 
+ *
  * <p>Usually these are only used internally by {@link Ext.data.proxy.Proxy} classes</p>
- * 
- * @constructor
- * @param {Object} config Optional config object
+ *
  */
 Ext.define('Ext.data.Batch', {
     mixins: {
         observable: 'Ext.util.Observable'
     },
-    
+
     /**
-     * True to immediately start processing the batch as soon as it is constructed (defaults to false)
-     * @property autoStart
-     * @type Boolean
+     * @property {Boolean} autoStart
+     * True to immediately start processing the batch as soon as it is constructed.
      */
     autoStart: false,
-    
+
     /**
+     * @property {Number} current
      * The index of the current operation being executed
-     * @property current
-     * @type Number
      */
     current: -1,
-    
+
     /**
+     * @property {Number} total
      * The total number of operations in this batch. Read only
-     * @property total
-     * @type Number
      */
     total: 0,
-    
+
     /**
+     * @property {Boolean} isRunning
      * True if the batch is currently running
-     * @property isRunning
-     * @type Boolean
      */
     isRunning: false,
-    
+
     /**
+     * @property {Boolean} isComplete
      * True if this batch has been executed completely
-     * @property isComplete
-     * @type Boolean
      */
     isComplete: false,
-    
+
     /**
+     * @property {Boolean} hasException
      * True if this batch has encountered an exception. This is cleared at the start of each operation
-     * @property hasException
-     * @type Boolean
      */
     hasException: false,
-    
+
     /**
-     * True to automatically pause the execution of the batch if any operation encounters an exception (defaults to true)
-     * @property pauseOnException
-     * @type Boolean
+     * @property {Boolean} pauseOnException
+     * True to automatically pause the execution of the batch if any operation encounters an exception
      */
     pauseOnException: true,
-    
-    constructor: function(config) {   
+
+    /**
+     * Creates new Batch object.
+     * @param {Object} [config] Config object
+     */
+    constructor: function(config) {
         var me = this;
-                     
+
         me.addEvents(
           /**
            * @event complete
@@ -76,7 +85,7 @@ Ext.define('Ext.data.Batch', {
            * @param {Object} operation The last operation that was executed
            */
           'complete',
-          
+
           /**
            * @event exception
            * Fired when a operation encountered an exception
@@ -84,7 +93,7 @@ Ext.define('Ext.data.Batch', {
            * @param {Object} operation The operation that encountered the exception
            */
           'exception',
-          
+
           /**
            * @event operationcomplete
            * Fired when each operation of the batch completes
@@ -93,29 +102,28 @@ Ext.define('Ext.data.Batch', {
            */
           'operationcomplete'
         );
-        
+
         me.mixins.observable.constructor.call(me, config);
-        
+
         /**
          * Ordered array of operations that will be executed by this batch
-         * @property operations
-         * @type Array
+         * @property {Ext.data.Operation[]} operations
          */
         me.operations = [];
     },
-    
+
     /**
      * Adds a new operation to this batch
      * @param {Object} operation The {@link Ext.data.Operation Operation} object
      */
     add: function(operation) {
         this.total++;
-        
+
         operation.setBatch(this);
-        
+
         this.operations.push(operation);
     },
-    
+
     /**
      * Kicks off the execution of the batch, continuing from the next operation if the previous
      * operation encountered an exception, or if execution was paused
@@ -123,10 +131,10 @@ Ext.define('Ext.data.Batch', {
     start: function() {
         this.hasException = false;
         this.isRunning = true;
-        
+
         this.runNextOperation();
     },
-    
+
     /**
      * @private
      * Runs the next operation, relative to this.current.
@@ -134,14 +142,14 @@ Ext.define('Ext.data.Batch', {
     runNextOperation: function() {
         this.runOperation(this.current + 1);
     },
-    
+
     /**
      * Pauses execution of the batch, but does not cancel the current operation
      */
     pause: function() {
         this.isRunning = false;
     },
-    
+
     /**
      * Executes a operation by its numeric index
      * @param {Number} index The operation index to run
@@ -151,17 +159,17 @@ Ext.define('Ext.data.Batch', {
             operations = me.operations,
             operation  = operations[index],
             onProxyReturn;
-        
+
         if (operation === undefined) {
             me.isRunning  = false;
             me.isComplete = true;
             me.fireEvent('complete', me, operations[operations.length - 1]);
         } else {
             me.current = index;
-            
+
             onProxyReturn = function(operation) {
                 var hasException = operation.hasException();
-                
+
                 if (hasException) {
                     me.hasException = true;
                     me.fireEvent('exception', me, operation);
@@ -176,10 +184,10 @@ Ext.define('Ext.data.Batch', {
                     me.runNextOperation();
                 }
             };
-            
+
             operation.setStarted();
-            
+
             me.proxy[operation.action](operation, onProxyReturn, me);
         }
     }
-});
\ No newline at end of file
+});