Packageorg.restfulx.controllers
Classpublic class ChangeController
InheritanceChangeController Inheritance flash.events.EventDispatcher

If Synchronization is enabled, Change controller can be hooked up to Rx.changes to perform synchronization between 2 different service providers. source service provider must implement ISynchingServiceProvider while target service provider can be anything that implements the standard IServiceProvider interface.


Example
Setting up ChangeController
    private funtion init():void {
      ApplicationController.initialize([AIRServiceProvider, AS3JSONHTTPServiceProvider, DirectCouchDBHTTPServiceProvider], 
        AIRServiceProvider.ID, "yourairdbname");
      Rx.changes.setSyncProviders(ISyncingServiceProvider(Rx.services.getServiceProvider(AIRServiceProvider.ID)),
        Rx.services.getServiceProvider(AS3JSONHTTPServiceProvider.ID));
    }
    

Pushing data
    <mx:Button label="Push" click="{Rx.changes.push()}" enabled="{online}"/>
    

Pulling data
    <mx:Button label="Pull" click="{Rx.changes.pull()}" enabled="{online}"/>
    



Public Properties
 PropertyDefined by
  errors : RxCollection
If there were synchronization errors (e.g.
ChangeController
  pushCount : int
Number of objects still left to push
ChangeController
Public Methods
 MethodDefined by
  
ChangeController(source:ISyncingServiceProvider = null, destination:IServiceProvider = null, onSuccess:Function = null, onFailure:Function = null)
ChangeController
  
Used internally to finish push session.
ChangeController
  
pull(... models):void
Pulls changes from destination service provider and passes them to the source service provider
ChangeController
  
push(... models):void
Pushes changes from source service provider to target/destination service provider
ChangeController
  
Set sync providers on existing reference.
ChangeController
Protected Methods
 MethodDefined by
  
ChangeController
  
onDirtyChanges(result:Object, token:Object = null):void
ChangeController
  
onDirtyFault(info:Object, token:Object = null):void
ChangeController
Public Constants
 ConstantDefined by
  CREATE : String = "N"
[static] Create flag used to tag instances marked for create but not yet created/synced
ChangeController
  DELETE : String = "D"
[static] Delete flag used to tag instances marked for deletion but not yet deleted/synced
ChangeController
  UPDATE : String = "U"
[static] Update flag used to tag instances marked for update but not yet updated/synced
ChangeController
Property detail
errorsproperty
public var errors:RxCollection

If there were synchronization errors (e.g. destiation service provider couldn't sync a specific object), they are available in this collection.

pushCountproperty 
public var pushCount:int

Number of objects still left to push

Constructor detail
ChangeController()constructor
public function ChangeController(source:ISyncingServiceProvider = null, destination:IServiceProvider = null, onSuccess:Function = null, onFailure:Function = null)

Parameters
source:ISyncingServiceProvider (default = null) — ISyncingServiceProvider implementation that changes come from
 
destination:IServiceProvider (default = null) — IServiceProvider implemnetation that the changes should go to
 
onSuccess:Function (default = null)
 
onFailure:Function (default = null)
Method detail
notifyPushEnd()method
public function notifyPushEnd():void

Used internally to finish push session.

onCacheUpdate()method 
protected function onCacheUpdate(event:CacheUpdateEvent):voidParameters
event:CacheUpdateEvent
onDirtyChanges()method 
protected function onDirtyChanges(result:Object, token:Object = null):voidParameters
result:Object
 
token:Object (default = null)
onDirtyFault()method 
protected function onDirtyFault(info:Object, token:Object = null):voidParameters
info:Object
 
token:Object (default = null)
pull()method 
public function pull(... models):void

Pulls changes from destination service provider and passes them to the source service provider

Parameters
... models

Example
When you want to pull specific models with no metadata use the following syntax
       Rx.changes.pull(Model1, Model2, Model3)
     

When you want to pull all the models do this
       Rx.changes.pull()
     

When you want to specify extra metadata to send with the pull request for each model do this
       Rx.changes.pull({type: Type1, metadata: {page:1, limit: 500}}, {type: Type2, metadata: {page: 1, limit:500}});
     

push()method 
public function push(... models):void

Pushes changes from source service provider to target/destination service provider

Parameters
... models
setSyncProviders()method 
public function setSyncProviders(source:ISyncingServiceProvider, destination:IServiceProvider):void

Set sync providers on existing reference.

Parameters
source:ISyncingServiceProvider — ISyncingServiceProvider implementation that changes come from
 
destination:IServiceProvider — IServiceProvider implemnetation that the changes should go to
Constant detail
CREATEconstant
public static const CREATE:String = "N"

Create flag used to tag instances marked for create but not yet created/synced

DELETEconstant 
public static const DELETE:String = "D"

Delete flag used to tag instances marked for deletion but not yet deleted/synced

UPDATEconstant 
public static const UPDATE:String = "U"

Update flag used to tag instances marked for update but not yet updated/synced