tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/314-do-you-let-the-commands-response-to-servicesRobotlegs: Discussion 2018-10-18T16:35:18Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/32797782010-10-09T10:48:26Z2010-10-09T10:48:26ZDo you let the commands response to services <div><p>Hi Nikos,</p>
<p>2 approaches in one of my applications:</p>
<ul>
<li>1
SomeService</li>
</ul>
<pre>
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);
}
</pre>
<p>SomeModel dispatches an event with SomeVO as a payload</p>
<p>SomeMediator listens for that event and passes the data to the SomeView</p>
<ul>
<li>2
SomeService onSomeResult dispatches an event with the result as the payload, SomeMediator listens for it, and it does something because of the payload or with it...<br />
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<br />
</li>
</ul>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/32797782010-10-09T15:15:35Z2010-10-09T15:15:35ZDo you let the commands response to services <div><p>I like the Promise approach that Shaun has here:</p>
<p><a href="http://gist.github.com/470851">http://gist.github.com/470851</a></p></div>Joel Hookstag:robotlegs.tenderapp.com,2009-10-18:Comment/32797782010-10-13T12:03:15Z2010-10-13T12:03:15ZDo you let the commands response to services <div><p>Is the Promise approach still valid when we have the asyncCommand?</p></div>Nikos tag:robotlegs.tenderapp.com,2009-10-18:Comment/32797782010-10-15T10:25:00Z2010-10-15T10:25:00ZDo you let the commands response to services <div><p>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.</p>
<p>Opinions?</p></div>Nikos