just call responder.result or reponder.fault directly from your delegate : so lets say you need to sum 2 integers ( 1+ 1), and for your remote version you have a call to do that, say it's sum(int1:int, int2:int)
you remote delegate would have a method looking rather like this :
(assume integerPairVo is just a data VO holding the properties int1 and int2)
public function sum( integerPairVo:IntegerPairVo):void
{
var call:Object = service.sum(integerPairVo) ;
call.addResponder( responder );
}
That's easy, the responder is passed to the service, which then calls
responder.result or responder.fault when it gets it's result (or error).
If you want to perform the sum locally (perhaps it's a bad example, more
realistically it would reading a file synchronously, or a shared object
perhaps),
then all you need to do is do the calculation, then call the responders
result method yourself in your delegate, perhaps something like this :
public function sum( integerPairVo:IntegerPairVo):void
{
try
{
var summedIntegers:int = integerPairVo.int1 + integerPairVo.int2; // OK,
this is unlikely to fail, but I hope you get the idea.
responder.result(summedIntegers);
}
catch(error:Error)
{
responder.fault(error.message);
}
}
-----Original Message-----
From: [email protected] on behalf of chigwell23
Sent: Sun 04/05/2008 23:03
To: [email protected]
Subject: [flexcoders] Re: Cairngorm - always event, always command? Part2
Appreciate any clarification on the following - am converting my
previously non -service embedded functions to Cairngorm. Command +
Delegate works by the responder calling "result" or "fauLt" in
Command. Responder is added to Service, right? So in my banal example
of "add 1 + 1", where does the responder come from that calls result()
in Command?
My typical Delegate would be
public function signon( signonAttempt:LoginVO ):void
{
var call:Object = service.signon(signonAttempt) ;
call.addResponder( responder );
}
Who does the "1+1"?. I have got pretty good at learning from example
code - I find it very interesting that all examples of Cairngorm show
a call to the backend - there are no examples of using Cairngorm to
execute any other kind of function e.g. my real need to manipulate a
SO on the local client - which I do embedded but want to keep to a
standard (Cairngorm). As always, TIA,
Mic.
--- In [email protected], "Douglas Knudsen"
<[EMAIL PROTECTED]> wrote:
>
> certainly use the pattern for reading from a SO. Your Command should be
> clueless if its a SO or RPC call, the Delegate does that job.
Consider the
> case where you switch from storage in your SO to say S3 or a big
phat Oracle
> DB. You only need change your delegate. You can also have a
Command that
> mutates your Model in some way that doesn't need any Delegate or
Responder.
>
> Now, if you just want to add 1 + 1, try Googling on 'AbacusCommand'
hehe!
>
> DK
>
> On Fri, May 2, 2008 at 3:55 AM, chigwell23 <[EMAIL PROTECTED]> wrote:
>
> > Thanks Jim. With the Delegate and Responder stuff, it seems on the
> > surface that Cairngorm is predisposed to service/backend communication
> > solutions. Taking the example of a function that at the moment is
> > reading Shared object data - how would this be Cairngormed? When the
> > Command code is reached, does one just stay there and run the SO code?
> > i.e. does one move all the function code into a Command function for
> > non-service oriented activity? Forget Delegates and Responders?
> >
> > Really interested in what people think here, as the majority of
> > Cairngorm examples I have seen, have used Cairngorm events for the
> > service-oriented stuff, but have "regressed" to embedded functions for
> > the rest.
> >
> > I would really like someone to show me how "add 1+ 1" is Cairngormed
> > .... being serious here! Thanks in advance,
> >
> > Mic.
> >
> > --- In [email protected] <flexcoders%40yahoogroups.com>, "Jim
> > Hayes" <jim@> wrote:
> > >
> > >
> > > I can't see how you'd benefit from sidestepping the cairngorm event
> > -> command way of working in this case.
> > > If you use a service to get the IP address then it's asynchronous,
> > and has a few possible outcomes.
> > > I can't see why you wouldn't want to wait for it's "got one of those
> > results or an error" event and then deal with the outcome.
> > > Which is where the cairngorm way of doing things is really helpful.
> > >
> > > If it's synchronous (like opening a database or prefs file in AIR,
> > say), then you could maybe skip cairngorm (I do, and get away with it,
> > mostly).
> > > In which case I can't see the benefit of thinking of (or packaging )
> > it as a cairngorm command. I'd rather put it somewhere else and know
> > it was a different thing.
> > >
> > > But what I've found most of the time is that if you're going to do a
> > cairngorm app then it's really worth going with the flow and doing
> > pretty well everything that way,
> > > even if it does mean writing 3 classes when you could get away with
> > a local method.
> > > Generally, when I've made short cuts like that it's come back and
> > bitten me on the arse.
> > > I do still do it when I'm in experimental/creative or lazy mode, but
> > now I'll try to refactor it into the cairngorm way sooner rather than
> > later.
> > > Which is sometimes a bit boring, but there you go.
> > >
> > > Hope that makes (at least some) sense!
> > >
> > >
> > >
> > > -----Original Message-----
> > > From: [email protected] <flexcoders%40yahoogroups.com> on
> > behalf of chigwell23
> > > Sent: Thu 01/05/2008 22:51
> > > To: [email protected] <flexcoders%40yahoogroups.com>
> > > Subject: [flexcoders] Cairngorm - always event, always command?
> > >
> > > pseudocode:
> > >
> > > creationComplete
> > > var ipAddress:String
> > > ipAddress = getUserIP()
> > >
> > >
> > > function getuserIP():String{
> > >
> > > // use Services to go out to ColdFusion which can tell me user IP
> > > return IP
> > > }
> > >
> > > But Cairngorm encapsulates "actions" into commands which are
driven by
> > > an event and a delegate. So how does it handle examples like the one
> > > above? Should I create a getIP event, which is dispatched from
> > > creationComplete, and use the standard command/delegate path. If the
> > > event is not necessary, and it still makes sense to put the "action"
> > > in a command, how would that command get activated without the
> > > Cairngorm event process? I know what I mean <grin>. TIA,
> > >
> > > Mic.
> > >
> > >
> > >
> > > __________________________________________________________
> > > This communication is from Primal Pictures Ltd., a company
> > registered in England and Wales with registration No. 02622298 and
> > registered office: 4th Floor, Tennyson House, 159-165 Great Portland
> > Street, London, W1W 5PA, UK. VAT registration No. 648874577.
> > >
> > > This e-mail is confidential and may be privileged. It may be read,
> > copied and used only by the intended recipient. If you have received
> > it in error, please contact the sender immediately by return e-mail or
> > by telephoning +44(0)20 7637 1010. Please then delete the e-mail and
> > do not disclose its contents to any person.
> > > This email has been scanned for Primal Pictures by the MessageLabs
> > Email Security System.
> > > __________________________________________________________
> > >
> >
> >
> >
>
>
>
> --
> Douglas Knudsen
> http://www.cubicleman.com
> this is my signature, like it?
>
______________________________________________________________________
This communication is from Primal Pictures Ltd., a company registered in
England and Wales with registration No. 02622298 and registered office: 4th
Floor, Tennyson House, 159-165 Great Portland Street, London, W1W 5PA, UK. VAT
registration No. 648874577.
This e-mail is confidential and may be privileged. It may be read, copied and
used only by the intended recipient. If you have received it in error, please
contact the sender immediately by return e-mail or by telephoning +44(0)20 7637
1010. Please then delete the e-mail and do not disclose its contents to any
person.
This email has been scanned for Primal Pictures by the MessageLabs Email
Security System.
______________________________________________________________________<<winmail.dat>>

