<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The source code</title>
- <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
- <script type="text/javascript" src="../prettify/prettify.js"></script>
+ <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
<style type="text/css">
.highlight { display: block; background-color: #ddd; }
</style>
<pre class="prettyprint lang-js"><span id='Ext-data-Batch'>/**
</span> * @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>
- *
+ *
*/
Ext.define('Ext.data.Batch', {
mixins: {
observable: 'Ext.util.Observable'
},
-
+
<span id='Ext-data-Batch-property-autoStart'> /**
-</span> * True to immediately start processing the batch as soon as it is constructed (defaults to false)
- * @property autoStart
- * @type Boolean
+</span> * @property {Boolean} autoStart
+ * True to immediately start processing the batch as soon as it is constructed.
*/
autoStart: false,
-
+
<span id='Ext-data-Batch-property-current'> /**
-</span> * The index of the current operation being executed
- * @property current
- * @type Number
+</span> * @property {Number} current
+ * The index of the current operation being executed
*/
current: -1,
-
+
<span id='Ext-data-Batch-property-total'> /**
-</span> * The total number of operations in this batch. Read only
- * @property total
- * @type Number
+</span> * @property {Number} total
+ * The total number of operations in this batch. Read only
*/
total: 0,
-
+
<span id='Ext-data-Batch-property-isRunning'> /**
-</span> * True if the batch is currently running
- * @property isRunning
- * @type Boolean
+</span> * @property {Boolean} isRunning
+ * True if the batch is currently running
*/
isRunning: false,
-
+
<span id='Ext-data-Batch-property-isComplete'> /**
-</span> * True if this batch has been executed completely
- * @property isComplete
- * @type Boolean
+</span> * @property {Boolean} isComplete
+ * True if this batch has been executed completely
*/
isComplete: false,
-
+
<span id='Ext-data-Batch-property-hasException'> /**
-</span> * True if this batch has encountered an exception. This is cleared at the start of each operation
- * @property hasException
- * @type Boolean
+</span> * @property {Boolean} hasException
+ * True if this batch has encountered an exception. This is cleared at the start of each operation
*/
hasException: false,
-
+
<span id='Ext-data-Batch-property-pauseOnException'> /**
-</span> * True to automatically pause the execution of the batch if any operation encounters an exception (defaults to true)
- * @property pauseOnException
- * @type Boolean
+</span> * @property {Boolean} pauseOnException
+ * True to automatically pause the execution of the batch if any operation encounters an exception
*/
pauseOnException: true,
-
+
<span id='Ext-data-Batch-method-constructor'> /**
</span> * Creates new Batch object.
- * @param {Object} config (optional) Config object
+ * @param {Object} [config] Config object
*/
- constructor: function(config) {
+ constructor: function(config) {
var me = this;
-
+
me.addEvents(
<span id='Ext-data-Batch-event-complete'> /**
</span> * @event complete
* @param {Object} operation The last operation that was executed
*/
'complete',
-
+
<span id='Ext-data-Batch-event-exception'> /**
</span> * @event exception
* Fired when a operation encountered an exception
* @param {Object} operation The operation that encountered the exception
*/
'exception',
-
+
<span id='Ext-data-Batch-event-operationcomplete'> /**
</span> * @event operationcomplete
* Fired when each operation of the batch completes
*/
'operationcomplete'
);
-
+
me.mixins.observable.constructor.call(me, config);
-
+
<span id='Ext-data-Batch-property-operations'> /**
</span> * Ordered array of operations that will be executed by this batch
- * @property operations
- * @type Array
+ * @property {Ext.data.Operation[]} operations
*/
me.operations = [];
},
-
+
<span id='Ext-data-Batch-method-add'> /**
</span> * 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);
},
-
+
<span id='Ext-data-Batch-method-start'> /**
</span> * Kicks off the execution of the batch, continuing from the next operation if the previous
* operation encountered an exception, or if execution was paused
start: function() {
this.hasException = false;
this.isRunning = true;
-
+
this.runNextOperation();
},
-
+
<span id='Ext-data-Batch-method-runNextOperation'> /**
</span> * @private
* Runs the next operation, relative to this.current.
runNextOperation: function() {
this.runOperation(this.current + 1);
},
-
+
<span id='Ext-data-Batch-method-pause'> /**
</span> * Pauses execution of the batch, but does not cancel the current operation
*/
pause: function() {
this.isRunning = false;
},
-
+
<span id='Ext-data-Batch-method-runOperation'> /**
</span> * Executes a operation by its numeric index
* @param {Number} index The operation index to run
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);
me.runNextOperation();
}
};
-
+
operation.setStarted();
-
+
me.proxy[operation.action](operation, onProxyReturn, me);
}
}