Hi,
ok, let's go:
1.- REMOTEOBJECTS: You will have a mxml file that extends from Crux
BeanProvider. Let's call it ServicesConfig.mxml. There you have all you
mx:RemoteObject objects. So this object will provide all remote objects to
the rest of your app:
<mx:RemoteObject id="loginService"
destination="loginService"
channelSet="{loginChannel}"
showBusyCursor="true"/>
2.- SERVICE: Then you have a "delegate" like in Cairngorm where you inject
the remote object:
[Inject(source="loginService", required="true")]
public var service :RemoteObject = null;
So the remoteobject with name "loginService" will be injected in the public
var service. In this delegate you can do things like this:
public function recoverPassword(username :String, password :String) :
AsyncToken {
return service.recoverPassword(username, password);
}
3.- CONTROLLER: Here you have controller methods that will be called with
events and this will in the end call service methods in the delegate layer:
[EventHandler(event="LoginEvent.RECOVER_PASSWORD", properties="password")]
public function passwordRecovery(password :String) :void {
executeServiceCall(loginDelegate.recoverPassword(model.recoverUsername,
password), passwordRecoveryHandler);
}
executeServiceCall is a Crux function that allow you to call a service
method and attach a result and fault handlers that will be on this
controller. So in a controller you have that method plus two handlers
(result and fault, but probably just the first since the second use to be
the same reusable for all)
4.- EVENT: You extend from CruxEvent and have things like this:
public static const RECOVER_PASSWORD:String = "login.recoverPassword";
that match with the one in the controller.
5.- VIEW: Here you send the event:
var event :LoginEvent = new LoginEvent(LoginEvent.RECOVER_PASSWORD);
event.password = newpassword.text;
dispatchEvent(event);
And that's all
I think this is a very simple but powerful arquitecture that allows to
organize code in a very good way, while using plain objects without the
need of extensions and more, since objects are injected.
HTH
Carlos
El jue, 18 feb 2021 a las 16:51, Carlos Rovira (<[email protected]>)
escribió:
> Hi David,
>
> we have it here [1], but anyway I'll try to give a bit more info.
>
> [1] https://apache.github.io/royale-docs/libraries/crux/service-layer
>
> El jue, 18 feb 2021 a las 16:49, Carlos Rovira (<[email protected]>)
> escribió:
>
>> Hi David,
>>
>> I'll try to write this on a wiki, since I don't think we have a working
>> example. Hope to come back to you soon.
>>
>> El jue, 18 feb 2021 a las 15:54, David Slotemaker de Bruine (<
>> [email protected]>) escribió:
>>
>>> Hi All,
>>>
>>> I come from a Flex Cairngorm background and I am trying to get my head
>>> around Crux and the Crux example.
>>>
>>> I have gone through the tutorial and read the documentation. But I am
>>> stuck on where to place my RemoteObject tags and how to reference/call them.
>>>
>>> The first code snippet from:
>>>
>>> https://apache.github.io/royale-docs/libraries/crux/service-layer
>>>
>>> Shows the injection of a "userService" RemoteObject and a
>>> "ServiceHelper". Where should these code if I am using the CruxQuickStart
>>> as a base? In UserService.as? Where should the <mx:RemoteObject> be defined
>>> so it can be injected?
>>>
>>> Any help would be great!
>>>
>>> David
>>>
>>
>>
>> --
>> Carlos Rovira
>> Apache Member & Apache Royale PMC
>> *Apache Software Foundation*
>> http://about.me/carlosrovira
>>
>>
>
> --
> Carlos Rovira
> Apache Member & Apache Royale PMC
> *Apache Software Foundation*
> http://about.me/carlosrovira
>
>
--
Carlos Rovira
Apache Member & Apache Royale PMC
*Apache Software Foundation*
http://about.me/carlosrovira