Clear Up
SharpKit Reference

Operation Class

Represents a single read or write operation performed by a Proxy. Operation objects are used to enable communication between Stores and Proxies. Application developers should rarely need to interact with Operation objects directly.

Several Operations can be batched together in a batch.


Base Types


Name Description
Operation(object) Creates new Operation object.


Name Description
action The action being performed by this Operation. Should be one of 'create', 'read', 'update' or 'destroy'.
batch The batch that this Operation is a part of.
callback Function to execute when operation completed.
filters Optional array of filter objects. Only applies to 'read' actions.
groupers Optional grouping configuration. Only applies to 'read' actions where grouping is desired.
limit The number of records to load. Used on 'read' actions when paging is being used.
params Parameters to pass along with the request when performing the operation.
scope Scope for the callback function.
sorters Optional array of sorter objects. Only applies to 'read' actions.
start The start index (offset), used in paging when running a 'read' action.
synchronous True if this Operation is to be executed synchronously. This property is inspected by a Batch to see if a series of Operations can be executed in parallel or not. Defaults to: true


Name Description
actionCommitRecordsRe The RegExp used to categorize actions that require record commits. Defaults to: /^(?:create|update)$/i
actionSkipSyncRe The RegExp used to categorize actions that skip local record synchronization. This defaults to match 'destroy'. Defaults to: /^destroy$/i


Name Description
allowWrite() Checks whether this operation should cause writing to occur.
commitRecords(JsArray<T>) This method is called to commit data to this instance's records given the records in the server response. This is followed by calling on all those records (for 'create' and 'update' actions). If this action is 'destroy', any server records are ignored and the method is not called.
getError() Returns the error string or object that was set using setException
getRecords() Returns the records associated with this operation. For read operations the records as set by the Proxy will be returned (returns null if the proxy has not yet set the records). For create, update, and destroy operations the operation's initially configured records will be returned, although the proxy may modify these records' data at some point after the operation is initialized.
getResultSet() Returns the ResultSet object (if set by the Proxy). This object will contain the model instances as well as meta data such as number of instances fetched, number available etc
hasException() Returns true if this Operation encountered an exception (see also getError)
isComplete() Returns true if the Operation has been completed
isRunning() Returns true if the Operation has been started but has not yet completed.
isStarted() Returns true if the Operation has been started. Note that the Operation may have started AND completed, see isRunning to test if the Operation is currently running.
setCompleted() Marks the Operation as completed.
setException(object) Marks the Operation as having experienced an exception. Can be supplied with an option error message/object.
setStarted() Marks the Operation as started.
setSuccessful() Marks the Operation as successful.
wasSuccessful() Returns true if the Operation has completed and was successful
© Copyright 2005-2011 SharpKit. All rights reserved.