diff --git a/framework/.actionScriptProperties b/framework/.actionScriptProperties index d75926b..759f87c 100644 --- a/framework/.actionScriptProperties +++ b/framework/.actionScriptProperties @@ -1,6 +1,6 @@ - + diff --git a/framework/src/org/restfulx/Rx.as b/framework/src/org/restfulx/Rx.as index 45ee4ee..843b71a 100644 --- a/framework/src/org/restfulx/Rx.as +++ b/framework/src/org/restfulx/Rx.as @@ -251,6 +251,15 @@ package org.restfulx { */ public static var authenticityToken:String; + /** + * If true, show the busy cursor when making service calls; if false, do not show it. + * The default is true since this presents more information to the user. However, in a + * larger application it is sometimes desirable to hide this from users so that they can + * begin using the application without dealing with a watch cursor while there are still + * many calls happening in the background. + */ + public static var useBusyCursor:Boolean = true; + /** default error namespace used by service providers */ public static const DEFAULT_ERROR_FIELD:String = ":base"; @@ -320,7 +329,8 @@ package org.restfulx { * @return new filtered RxCollection instance */ public static function filter(items:ArrayCollection, filter:Function = null):RxCollection { - var results:RxCollection = new RxCollection(items.toArray().slice(0)); + var source:Array = (items == null || items.source == null) ? [] : items.source.slice(0); + var results:RxCollection = new RxCollection(source); return RxCollection(filter$(results, filter)); } @@ -428,7 +438,7 @@ package org.restfulx { } /** - * Clears errors, defaultMetadata and the sessionToken (a half-harted attempt at cleaning up + * Clears errors, defaultMetadata and the sessionToken (a half-hearted attempt at cleaning up * framework state, a bullet-proof way, which also clears event listeners you may have is to * reload the app on logout.) */ diff --git a/framework/src/org/restfulx/controllers/AuxHTTPController.as b/framework/src/org/restfulx/controllers/AuxHTTPController.as index 52ecea6..a951cca 100644 --- a/framework/src/org/restfulx/controllers/AuxHTTPController.as +++ b/framework/src/org/restfulx/controllers/AuxHTTPController.as @@ -270,8 +270,9 @@ package org.restfulx.controllers { Rx.log.debug("sending request to URL:" + service.url + " with method: " + service.method + " and content:" + ((service.request == null) ? "null" : "\r" + ObjectUtil.toString(service.request))); - - CursorManager.setBusyCursor(); + if (Rx.useBusyCursor) { + CursorManager.setBusyCursor(); + } var call:AsyncToken = service.send(); if (responder) { @@ -287,7 +288,9 @@ package org.restfulx.controllers { } protected function unmarshall(data:Object):Object { - CursorManager.removeBusyCursor(); + if (Rx.useBusyCursor) { + CursorManager.removeBusyCursor(); + } try { return serializer.unmarshall(data.result); } catch (e:Error) { diff --git a/framework/src/org/restfulx/controllers/ModelsController.as b/framework/src/org/restfulx/controllers/ModelsController.as index 3096945..c7f8d6f 100644 --- a/framework/src/org/restfulx/controllers/ModelsController.as +++ b/framework/src/org/restfulx/controllers/ModelsController.as @@ -535,11 +535,13 @@ package org.restfulx.controllers { * @param useLazyModel if true dependencies marked with [Lazy] will be skipped (not fetched) * @param append set this to true if you don't want to nuke target ModelsCollection * @param targetServiceId service provider to use + * @param hard this is passed to the reset method (if true, reset the object hard, thus clearing the cache; if false, + * simply reset the state) */ public function reload(object:Object, optsOrOnSuccess:Object = null, onFailure:Function = null, nestedBy:Array = null, metadata:Object = null, fetchDependencies:Boolean = true, useLazyMode:Boolean = true, append:Boolean = false, - targetServiceId:int = -1):void { - reset(object); + targetServiceId:int = -1, hard:Boolean = false):void { + reset(object, hard); if (object is Class) { index(Class(object), optsOrOnSuccess, onFailure, nestedBy, metadata, fetchDependencies, useLazyMode, append, targetServiceId); @@ -601,7 +603,9 @@ package org.restfulx.controllers { private function invokeService(method:Function, service:IServiceProvider, operand:Object, serviceResponder:ServiceResponder, metadata:Object = null, nestedBy:Array = null):void { - CursorManager.setBusyCursor(); + if (Rx.useBusyCursor) { + CursorManager.setBusyCursor(); + } metadata = setServiceMetadata(metadata); dispatchEvent(new ServiceCallStartEvent); method.call(service, operand, serviceResponder, metadata, nestedBy); @@ -610,7 +614,9 @@ package org.restfulx.controllers { private function invokeCUDService(method:Function, service:IServiceProvider, operand:Object, serviceResponder:ServiceResponder, metadata:Object = null, nestedBy:Array = null, recursive:Boolean = false):void { - CursorManager.setBusyCursor(); + if (Rx.useBusyCursor) { + CursorManager.setBusyCursor(); + } metadata = setServiceMetadata(metadata); dispatchEvent(new ServiceCallStartEvent); method.call(service, operand, serviceResponder, metadata, nestedBy, recursive); diff --git a/framework/src/org/restfulx/services/ServiceResponder.as b/framework/src/org/restfulx/services/ServiceResponder.as index a568e13..8ab4adc 100644 --- a/framework/src/org/restfulx/services/ServiceResponder.as +++ b/framework/src/org/restfulx/services/ServiceResponder.as @@ -73,7 +73,9 @@ package org.restfulx.services { * @see mx.rpc.IResponder#result */ public function result(event:Object):void { - CursorManager.removeBusyCursor(); + if (Rx.useBusyCursor) { + CursorManager.removeBusyCursor(); + } Rx.models.dispatchEvent(new ServiceCallStopEvent); if (handler != null) { if (!service.hasErrors(event.result)) { @@ -121,7 +123,9 @@ package org.restfulx.services { * @see mx.rpc.IResponder#fault */ public function fault(error:Object):void { - CursorManager.removeBusyCursor(); + if (Rx.useBusyCursor) { + CursorManager.removeBusyCursor(); + } delete Rx.models.state.waiting[modelType]; Rx.models.dispatchEvent(new ServiceCallStopEvent); invokeOnFailure(error); diff --git a/framework/src/org/restfulx/services/air/AIRServiceProvider.as b/framework/src/org/restfulx/services/air/AIRServiceProvider.as index e07824b..80a85a8 100644 --- a/framework/src/org/restfulx/services/air/AIRServiceProvider.as +++ b/framework/src/org/restfulx/services/air/AIRServiceProvider.as @@ -68,7 +68,7 @@ package org.restfulx.services.air { protected var sql:Dictionary; - protected var connection:SQLConnection; + public var connection:SQLConnection; private var pending:Array;