(Adobe® Flex™ Data Services 2 only)
Packagemx.data
Classpublic class DataStore
InheritanceDataStore Inheritance EventDispatcher Inheritance Object

A DataStore batches transactions for one or more DataService instances. It manages the set of pending changes destined for the server and also stores the set of conflicts received from the server. By default, if your DataService does not have managed associations, it automatically gets its own independent DataStore. Each call to the commit() method send only changes made to that DataService.

When you use managed associations, the default changes so that all DataService instances that share the same set of channels and have the same value of the use-transactions flag share the same DataStore. When you are sharing a DataStore, a single call to the commit() method applies to all changes made by all DataService instances sharing that DataStore. The default changes because with managed associations, it is possible that changes between destinations can have dependencies so it is important to preserve the order of operations on the client when sending messages to the server.

If you want to change the default, you can create your own DataStore and manually assign it to one or more dataStore properties of a DataService. Do this when you first initialize your DataService, before you have issued any other DataService api calls such as fill or getItem. Note that all DataServices which share the same DataStore should be using the same set of channels and should also have the same value of the use-transactions flag.

See also

Creating a distributed data application


Public Properties
 PropertyDefined by
  autoCommit : Boolean
If set to true, operations that modify the state managed by the DataService are committed immediately.
DataStore
  autoMerge : Boolean
If set to false, when changes are pushed from the server to the client they are not immediately applied.
DataStore
  commitRequired : Boolean
[read-only] Indicates if there are pending updates that must be committed.
DataStore
  conflicts : Conflicts
[read-only] Returns a list of conflicts for all managed items.
DataStore
  connected : Boolean
[read-only] Indicates whether the DataStore is connected.
DataStore
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  mergeRequired : Boolean
[read-only] Indicates if there are any pending changes that must be merged.
DataStore
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
  requestTimeout : int
Provides access to the request timeout in seconds for an operation.
DataStore
Public Methods
 MethodDefined by
  
DataStore(destination:String, useTransactions:Boolean)
Normally, a DataStore is created automatically for you but you can create your own DataStore and assign it to the dataStore property of a DataService.
DataStore
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
EventDispatcher
  
Commits any pending changes for all collections currently managed by this DataService.
DataStore
 Inherited
Dispatches an event into the event flow.
EventDispatcher
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
  
Merges any pending updates into the managed set of objects.
DataStore
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
  
Reverts all pending (uncommitted) changes for all DataServices managed by this DataStore.
DataStore
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
Events
 EventSummaryDefined by
 Inherited Dispatched when Flash Player gains operating system focus and becomes active.EventDispatcher
   Dispatched when a conflict is detected between either pending changes on this client and changes submitted by another client, or when changes submitted by this client result detect a conflict error at the remote destination.DataStore
 Inherited Dispatched when Flash Player loses operating system focus and is becoming inactive.EventDispatcher
   The FaultEvent.FAULT event is dispatched when the commit call returns an error.DataStore
   The ResultEvent.RESULT event is dispatched when the commit call successfully returns.DataStore
Property detail
autoCommitproperty
autoCommit:Boolean  [read-write]

If set to true, operations that modify the state managed by the DataService are committed immediately. If set to false, you must explicitly call the commit() method to send the changes to the server.

Implementation
    public function get autoCommit():Boolean
    public function set autoCommit(value:Boolean):void
autoMergeproperty 
autoMerge:Boolean  [read-write]

If set to false, when changes are pushed from the server to the client they are not immediately applied. Instead, the mergeRequired property is set to true. You can listen for change events on this property to be notified of when a merge needs to be applied. To merge changes, you call the merge() method and all changes are applied. You are not able to commit any changes when there are any changes that must be merged.

Implementation
    public function get autoMerge():Boolean
    public function set autoMerge(value:Boolean):void
commitRequiredproperty 
commitRequired:Boolean  [read-only]

Indicates if there are pending updates that must be committed.

This property can be used as the source for data binding.

Implementation
    public function get commitRequired():Boolean
conflictsproperty 
conflicts:Conflicts  [read-only]

Returns a list of conflicts for all managed items.

This property can be used as the source for data binding.

Implementation
    public function get conflicts():Conflicts
connectedproperty 
connected:Boolean  [read-only]

Indicates whether the DataStore is connected.

Implementation
    public function get connected():Boolean
mergeRequiredproperty 
mergeRequired:Boolean  [read-only]

Indicates if there are any pending changes that must be merged.

This property can be used as the source for data binding.

Implementation
    public function get mergeRequired():Boolean
requestTimeoutproperty 
requestTimeout:int  [read-write]

Provides access to the request timeout in seconds for an operation. A value less than or equal to zero prevents request timeout.

Implementation
    public function get requestTimeout():int
    public function set requestTimeout(value:int):void
Constructor detail
DataStore()constructor
public function DataStore(destination:String, useTransactions:Boolean)

Normally, a DataStore is created automatically for you but you can create your own DataStore and assign it to the dataStore property of a DataService. To do this, you must ensure all data services that share the same data store use the same channel set and have the same value of the use-transactions configuration setting. Use this constructor to create a DataStore where the destination parameter contains the destination of one of the DataServices using this data store. This is just used to look up the channel set. You also should provide the value for the use-transactions flag for this data store.

Parameters
destination:String
 
useTransactions:Boolean
Method detail
commit()method
public function commit():AsyncToken

Commits any pending changes for all collections currently managed by this DataService. When the autoCommit property is true, transactions are not be used. To use transactions, set the autoCommit property to false and call this method directly.

Returns
AsyncToken — Object that is returned in call property of either the ResultEvent.RESULT or in the FaultEvent.FAULT. Custom data can be attached to this object and inspected later during the event handling phase.
merge()method 
public function merge():void

Merges any pending updates into the managed set of objects. The process of merging changes can detect conflicts.

revertChanges()method 
public function revertChanges():Boolean

Reverts all pending (uncommitted) changes for all DataServices managed by this DataStore.

Returns
Boolean — true if any changes were reverted.
Event detail
conflictevent 
Event object type: mx.data.events.DataConflictEvent
DataConflictEvent.type property = mx.data.events.DataConflictEvent.CONFLICT

Dispatched when a conflict is detected between either pending changes on this client and changes submitted by another client, or when changes submitted by this client result detect a conflict error at the remote destination. The DataStore dispatches conflict events for all destinations which share the DataStore, or you can listen for conflict events for a specific type on a DataService. Use the DataStore when you have an object with associations as in that case, you may need to resolve conflicts in a specific order to maintain integrity of those associations.

The CONFLICT event type.

The properties of the event object have the following values:

PropertyValue
bubblesfalse
cancelablefalse
currentTargetThe Object that defines the event listener that handles the event. For example, if you use myButton.addEventListener() to register an event listener, myButton is the value of the currentTarget.
conflict The Conflict object that holds the conflict that occurred.
message The Message associated with this event.
targetThe Object that dispatched the event; it is not always the Object listening for the event. Use the currentTarget property to always access the Object listening for the event.
faultevent  
Event object type: mx.rpc.events.FaultEvent
FaultEvent.type property = mx.rpc.events.FaultEvent.FAULT

The FaultEvent.FAULT event is dispatched when the commit call returns an error.

The FAULT event type.

The properties of the event object have the following values:

PropertyValue
bubblesfalse
cancelabletrue, calling preventDefault() from the associated token's responder.fault method will prevent the service or operation from dispatching this event
currentTargetThe Object that defines the event listener that handles the event. For example, if you use myButton.addEventListener() to register an event listener, myButton is the value of the currentTarget.
faultThe Fault object that contains the details of what caused this event.
messageThe Message associated with this event.
targetThe Object that dispatched the event; it is not always the Object listening for the event. Use the currentTarget property to always access the Object listening for the event.
tokenThe token that represents the call to the method. Used in the asynchronous completion token pattern.
resultevent  
Event object type: mx.rpc.events.ResultEvent
ResultEvent.type property = mx.rpc.events.ResultEvent.RESULT

The ResultEvent.RESULT event is dispatched when the commit call successfully returns.

The RESULT event type.

The properties of the event object have the following values:

PropertyValue
bubblesfalse
cancelabletrue, preventDefault() from the associated token's responder.result method will prevent the service or operation from dispatching this event
currentTargetThe Object that defines the event listener that handles the event. For example, if you use myButton.addEventListener() to register an event listener, myButton is the value of the currentTarget.
message The Message associated with this event.
targetThe Object that dispatched the event; it is not always the Object listening for the event. Use the currentTarget property to always access the Object listening for the event.
resultResult that the RPC call returns.
tokenThe token that represents the indiviudal call to the method. Used in the asynchronous completion token pattern.




Take a survey


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flex/201/langref/mx/data/DataStore.html