Package | org.restfulx |
Class | public class Rx |
Commonly used and most important subsystems to be aware of are:
RxModel
instances, access model metadata, in-memory
cache and so on.IServiceProvider
implementations are registered with the ServicesController
and can be accessed via :
Rx.services.getServiceProvider(YourServiceProvider.ID)
Command
pattern Rx.commands.execute()
is a quick and easy way to
execute a command from anywhere in your code.RxModel
instances into
XML, JSON or Value Objects and visa-versa. In order to keep your application SWF
file small not all of them are linked in. The two most frequently used serializers
(namely XML and Value Object) are linked in though and are accessible via:
Rx.serializers.xml
and Rx.serializers.vo
respectively.model.create()
, model.update()
,
model.destroy()
can be automatically rolled-back or forwarded.
A number of static helper functions also live in this namespace including:
RxCollection
. There are two versions of this function.
One has side-effects in that it actually applies the filter directly on the
collection that was passed as an argument. The other one creates a new collection
based on the argument and applies the filter on that. This ensures that your source
collection remains the same. By convention RestfulX
helper functions that
have side-effects end with $ sign. For example,
Rx.filter
has no side-effects whereas Rx.filter$
does.RxCollection
.See also
Property | Defined by | ||
---|---|---|---|
airDatabaseName : String = "rxdb" [static]
Default database name to use for AIR applications.
| Rx | ||
airEnableDatabaseMigrations : Boolean = false [static]
Any properties that you add to your models can be automatically
added to your AIR database.
| Rx | ||
airEncryptionKey : ByteArray [static]
Encryption key to use for connection to AIR SQLite database (if this field is empty connection
will be unencrypted = default).
| Rx | ||
authenticityToken : String [static]
Stores current authenticity token.
| Rx | ||
changes : ChangeController
[static] exposes the Synchronization capable controller
| Rx | ||
commands : CommandsController
[static] auxiliary (typically non-CRUD) commands controller
| Rx | ||
couchDbDatabaseName : String = "rxdb" [static]
Default database name to use for apps talking to CouchDB directly.
| Rx | ||
couchDbRootUrl : String = "http://127.0.0.1:5984/" [static]
Root URL for CouchDB requests.
| Rx | ||
customHttpHeaders : Array [static]
Stores any extra HTTP headers that needs to be sent to the backend
| Rx | ||
defaultMetadata : Object [static]
Metadata allows us to tag arbitrary data along with any provider requests
this is typically useful with HTTP provider (but may be useful with other providers too).
| Rx | ||
defaultServiceId : int [static] default service provider to use.
| Rx | ||
enableSync : Boolean = false [static]
If set to true, synchronization controller will be initialized
| Rx | ||
enableUndoRedo : Boolean = false [static]
If set to true, undo/redo for create(), update() and destroy()
is enabled.
| Rx | ||
httpController : Class [static] default http controller implementation to use
| Rx | ||
httpControllerHandler : Function [static]
If http controller handler function is set, it allows you to override
behaviour of the
send() function in httpController . | Rx | ||
httpRootUrl : String = "/" [static] default root URL for HTTP requests, gets prefixed to CRUD and AUX HTTP operations
| Rx | ||
log : ILogger [static]
Framework logger.
| Rx | ||
models : ModelsController
[static] centralized access to RESTful CRUD operations on models
| Rx | ||
serializers : SerializersController
[static] exposes commonly used serializers (XML and VO)
| Rx | ||
services : ServicesController
[static] exposes currently registered service providers
| Rx | ||
sessionToken : String [static]
Stores current session id for use by URLRequest.
| Rx | ||
undoredo : UndoRedoController
[static] exposes the undo-redo capable controller
| Rx | ||
undoRedoStackSize : int = 10 [static]
Control the size of the undo-redo stack.
| Rx |
Method | Defined by | ||
---|---|---|---|
Rx(enforcer:PrivateEnforcer)
| Rx | ||
amf(optsOrOnResult:Object = null, onFault:Function = null, contentType:String = "application/x-www-form-urlencoded", resultFormat:String = "binary", serializer:ISerializer = null, rootUrl:String = null):AuxHTTPController
[static]
Handy shortcut for non-CRUD AMF operations.
| Rx | ||
enableLogging():void
[static]
Enables tracing for internal restfulx framework classes.
| Rx | ||
filter(items:ArrayCollection, filter:Function = null):RxCollection
[static]
Filters a given RxCollection with no side effects, a new restfulx array collection is created
that the filter is applied on.
| Rx | ||
[static]
Filters a given RxCollection in place, this version actually modifies the instance passed
in as the argument.
| Rx | ||
[static]
Applies a composite filter to a given RxCollection with no side effects, a new restfulx
array collection is created that the filters are applied on.
| Rx | ||
[static]
Applies a composite filter to a given RxCollection in place, this version actually modifies
the instance passed in as the argument.
| Rx | ||
http(optsOrOnResult:Object = null, onFault:Function = null, contentType:String = "application/x-www-form-urlencoded", resultFormat:String = "text", serializer:ISerializer = null, rootUrl:String = null):AuxHTTPController
[static]
Handy shortcut for non-CRUD HTTP operations.
| Rx | ||
merge(items:ArrayCollection, toAdd:Array, after:Boolean = false):RxCollection
[static]
Merges an array into a RxCollection (without side-effects).
| Rx | ||
reset():void
[static]
Clears errors, defaultMetadata and the sessionToken (a half-harted 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.)
| Rx | ||
[static]
Sorts a given RxCollection using SortFields (or anonymous objects) provided without
side effects.
| Rx | ||
[static]
Sorts a given RxCollection using SortFields (or anonymous objects) provided in
place.
| Rx |
Constant | Defined by | ||
---|---|---|---|
DEFAULT_ERROR_FIELD : String = ":base" [static] default error namespace used by service providers
| Rx |
airDatabaseName | property |
public static var airDatabaseName:String = "rxdb"
Default database name to use for AIR applications. Simply set
Rx.airDatabaseName
anywhere in your code to override. This is
usually done at application initialization.
Rx.airDatabaseName = "myairdb";
airEnableDatabaseMigrations | property |
public static var airEnableDatabaseMigrations:Boolean = false
Any properties that you add to your models can be automatically added to your AIR database. Set this variable to true if you want to enable this functionality.
NOTE: Given limitations in SQLite we can only add columns, existing columns will not be renamed or removed as you add/remove/rename properties in your models. It is your responsibility to migrate data and cleanup client databases if required.
airEncryptionKey | property |
public static var airEncryptionKey:ByteArray
Encryption key to use for connection to AIR SQLite database (if this field is empty connection will be unencrypted = default).
authenticityToken | property |
public static var authenticityToken:String
Stores current authenticity token.
changes | property |
public static var changes:ChangeController
exposes the Synchronization capable controller
commands | property |
public static var commands:CommandsController
auxiliary (typically non-CRUD) commands controller
couchDbDatabaseName | property |
public static var couchDbDatabaseName:String = "rxdb"
Default database name to use for apps talking to CouchDB directly. Simply set
Rx.couchDbdatabaseName
anywhere in your code to override. This is
usually done at application initialization.
Rx.couchDbDatabaseName = "foobar";
couchDbRootUrl | property |
public static var couchDbRootUrl:String = "http://127.0.0.1:5984/"
Root URL for CouchDB requests.
customHttpHeaders | property |
public static var customHttpHeaders:Array
Stores any extra HTTP headers that needs to be sent to the backend
defaultMetadata | property |
public static var defaultMetadata:Object
Metadata allows us to tag arbitrary data along with any provider requests this is typically useful with HTTP provider (but may be useful with other providers too).
Default metadata specifies metadata that always gets sent along. You can always provide
metadata on a per-ModelsController
CRUD method basis.
Example
Default metadata is typically an anonymous object
Rx.defaultMetadata = {foo: 'bar', bar: 'foo'};
defaultServiceId | property |
public static var defaultServiceId:int
default service provider to use. XMLHTTPServiceProvider.ID
is default.
enableSync | property |
public static var enableSync:Boolean = false
If set to true, synchronization controller will be initialized
enableUndoRedo | property |
public static var enableUndoRedo:Boolean = false
If set to true, undo/redo for create(), update() and destroy() is enabled.
httpController | property |
public static var httpController:Class
default http controller implementation to use
httpControllerHandler | property |
public static var httpControllerHandler:Function
If http controller handler function is set, it allows you to override
behaviour of the send()
function in httpController
.
public override function send(url:String, data:Object = null, method:int = AuxHTTPController.GET, responder:IResponder = null):void { var response:Object = null; if (Rx.httpControllerHandler != null) { response = Rx.httpControllerHandler(this, url, data, method); } responder.result(new ResultEvent(ResultEvent.RESULT, false, false, response)); }
httpRootUrl | property |
public static var httpRootUrl:String = "/"
default root URL for HTTP requests, gets prefixed to CRUD and AUX HTTP operations
log | property |
public static var log:ILogger
Framework logger. In order to see any framework-level logging at all
you should call Rx.enableLogging()
anywhere in your
code. This is typically done at application initialization.
You can control log level by passing appropriate argument to
Rx.enableLogging()
, such as LogEventLevel.INFO
See also
models | property |
public static var models:ModelsController
centralized access to RESTful CRUD operations on models
serializers | property |
public static var serializers:SerializersController
exposes commonly used serializers (XML and VO)
services | property |
public static var services:ServicesController
exposes currently registered service providers
sessionToken | property |
public static var sessionToken:String
Stores current session id for use by URLRequest. If your application requires authentication, it is recommended that you return a session token from the server as a result of login. This session token will be re-used for subsequent calls until the user logs out. This is particularly important for file uploads.
undoredo | property |
public static var undoredo:UndoRedoController
exposes the undo-redo capable controller
undoRedoStackSize | property |
public static var undoRedoStackSize:int = 10
Control the size of the undo-redo stack. the default is 10 (undo redo must be enabled with Rx.enableUndoRedo = true) before this will have any effect
Rx | () | constructor |
public function Rx(enforcer:PrivateEnforcer)
Parameters
enforcer:PrivateEnforcer |
amf | () | method |
public static function amf(optsOrOnResult:Object = null, onFault:Function = null, contentType:String = "application/x-www-form-urlencoded", resultFormat:String = "binary", serializer:ISerializer = null, rootUrl:String = null):AuxHTTPController
Handy shortcut for non-CRUD AMF operations. Works in much the same way as Rx.http except it expects to receive AMF serializes messages as response
ParametersoptsOrOnResult:Object (default = null ) — can be either an anonymous object of options or a result handler
function. Many functions in the framework can be called with named params specified
in an object or explicitly in the order required by the function. See the example above.
|
|
onFault:Function (default = null ) — function to call on URLLoader error
|
|
contentType:String (default = "application/x-www-form-urlencoded ") — content type for the request
|
|
resultFormat:String (default = "binary ") — how to treat the response from the server (binary is the default)
|
|
serializer:ISerializer (default = null ) — ISerializer implementation to use when unmarshalling responses. Use
this in conjunction with resultFormat. Default is AMFSerializer.
|
|
rootUrl:String (default = null ) — the URL to prefix to requests
|
AuxHTTPController —
AuxHTTPController instance
|
See also
Rx.amf(function(result:Object):void { trace(result); }).invoke("some/url/here");
This will send a GET request with no arguments to "some/url/here" and call anonymous function provided when the result comes back.
enableLogging | () | method |
public static function enableLogging():void
Enables tracing for internal restfulx framework classes. This is useful for debugging purposes. The log can be seen in the console of Flex Builder when you are ebugging as opposed to running your project.
filter | () | method |
public static function filter(items:ArrayCollection, filter:Function = null):RxCollection
Filters a given RxCollection with no side effects, a new restfulx array collection is created that the filter is applied on.
Parametersitems:ArrayCollection — ArrayCollection instance to filter
|
|
filter:Function (default = null ) — filter function
|
RxCollection —
new filtered RxCollection instance
|
filter$ | () | method |
public static function filter$(items:RxCollection, filter:Function = null):RxCollection
Filters a given RxCollection in place, this version actually modifies the instance passed in as the argument.
Parametersitems:RxCollection — ArrayCollection to filter (will be motified in place)
|
|
filter:Function (default = null ) — filter function
|
RxCollection —
original array collection with the filter applied
|
filters | () | method |
public static function filters(items:RxCollection, filters:Array = null):RxCollection
Applies a composite filter to a given RxCollection with no side effects, a new restfulx array collection is created that the filters are applied on.
Parametersitems:RxCollection — RxCollection instance to filter
|
|
filters:Array (default = null ) — an Array of filter functions
|
RxCollection —
new filtered RxCollection instance
|
filters$ | () | method |
public static function filters$(items:RxCollection, filters:Array = null):RxCollection
Applies a composite filter to a given RxCollection in place, this version actually modifies the instance passed in as the argument.
Parametersitems:RxCollection — RxCollection to filter (will be motified in place)
|
|
filters:Array (default = null ) — an Array of filter functions to apply
|
RxCollection —
original array collection with the filters applied
|
http | () | method |
public static function http(optsOrOnResult:Object = null, onFault:Function = null, contentType:String = "application/x-www-form-urlencoded", resultFormat:String = "text", serializer:ISerializer = null, rootUrl:String = null):AuxHTTPController
Handy shortcut for non-CRUD HTTP operations.
ParametersoptsOrOnResult:Object (default = null ) — can be either an anonymous object of options or a result handler
function. Many functions in the framework can be called with named params specified
in an object or explicitly in the order required by the function. See the example above.
|
|
onFault:Function (default = null ) — function to call on HTTPService error
|
|
contentType:String (default = "application/x-www-form-urlencoded ") — content type for the request
|
|
resultFormat:String (default = "text ") — how to treat the response from the server (text is the default)
|
|
serializer:ISerializer (default = null ) — ISerializer implementation to use when unmarshalling responses. Use
this in conjunction with resultFormat. Default is XMLSerializer.
|
|
rootUrl:String (default = null ) — the URL to prefix to requests
|
AuxHTTPController —
AuxHTTPController instance
|
See also
Rx.http(function(result:Object):void { trace(result); }).invoke("some/url/here");
This will send a GET request with no arguments to "some/url/here" and call anonymous function provided when the result comes back.
OrRx.http({ resultHandler: someFunctionToHandleResult, faultHandler: someFunctionToHandleFault, contentType: "application/xml" }).invoke({data: bla, method: "POST", unmarshall: true});
merge | () | method |
public static function merge(items:ArrayCollection, toAdd:Array, after:Boolean = false):RxCollection
Merges an array into a RxCollection (without side-effects). A new RxCollection is created/returned as a result.
Parametersitems:ArrayCollection — ArrayCollection to merge into
|
|
toAdd:Array — Array to merge
|
|
after:Boolean (default = false ) — if true toAdd gets appended else prepended
|
RxCollection —
a ewRxCollection
|
reset | () | method |
public static function reset():void
Clears errors, defaultMetadata and the sessionToken (a half-harted 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.)
sort | () | method |
public static function sort(items:RxCollection, fields:Array = null):RxCollection
Sorts a given RxCollection using SortFields (or anonymous objects) provided without side effects. A new sorted collection is returned.
Parametersitems:RxCollection — RxCollection to sort (will be not motified in place)
|
|
fields:Array (default = null ) — an Array of SortFields or anonymous objects that represent SortFields
|
RxCollection —
new array collection with the sorts applied
|
sort$ | () | method |
public static function sort$(items:RxCollection, fields:Array = null):RxCollection
Sorts a given RxCollection using SortFields (or anonymous objects) provided in place.
Parametersitems:RxCollection — RxCollection to sort (will be motified in place)
|
|
fields:Array (default = null ) — an Array of SortFields or anonymous objects that represent SortFields
|
RxCollection —
original array collection with the sorts applied
|
DEFAULT_ERROR_FIELD | constant |
public static const DEFAULT_ERROR_FIELD:String = ":base"
default error namespace used by service providers