Do you let the commands response to services
From my understanding people prefer to let the commands response to services and update the application rather than handling that stuff in services. What is your prefered method of handing the different responses from methods in your services in the command. My services typically use remote objects. Should the methods in the service return asnctokens or responers?
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Ondina D.F. on 09 Oct, 2010 10:48 AM
Hi Nikos,
2 approaches in one of my applications:
public function someRequest():void { responder=new Responder(onSomeResult, onServerFault); service.source="SomeRemoteClass"; service.getOperation("someRemoteMethod ").arguments=remoteModel.argumentsList; var asyncToken:AsyncToken=service.getOperation("someRemoteMethod").send(); asyncToken.addResponder(responder); } protected function onSomeResult(event:ResultEvent):void{ someModel.resultsArray=ArrayUtil.toArray(event.result); }SomeModel dispatches an event with SomeVO as a payload
SomeMediator listens for that event and passes the data to the SomeView
Sometimes I just need to dispatch an event from the Service without a payload, for example after saving data on server the Mediator just needs a confirmation that everything worked fine
Ondina
Support Staff 3 Posted by Joel Hooks on 09 Oct, 2010 03:15 PM
I like the Promise approach that Shaun has here:
http://gist.github.com/470851
4 Posted by Nikos Katsikanis on 13 Oct, 2010 12:03 PM
Is the Promise approach still valid when we have the asyncCommand?
5 Posted by Nikos Katsikanis on 15 Oct, 2010 10:25 AM
After thinking about this more it feels more natural to do all the after amfService method completion stuff in the actual service(using callbacks ) rather than passing it back to the command via callbacks in the command as I feel all this does is make it harder to figure out what it going on in your app.
Opinions?
Nikos Katsikanis closed this discussion on 06 Nov, 2010 12:36 PM.