tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/1038-no-subjectRobotlegs: Discussion 2012-09-14T07:09:03Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/185857662012-09-07T14:25:29Z2012-09-07T14:25:30ZNo subject<div><p>Some service methods in my Robotlegs app require parameters. I'm
wondering which solution is better:<br>
1. Mediators pass parameters to services<br>
2. Services aquire parameters from injected models</p></div>Marektag:robotlegs.tenderapp.com,2009-10-18:Comment/185857662012-09-07T14:52:29Z2012-09-07T14:52:29ZNo subject<div><p>Hi Marek,</p>
<blockquote>
<p>1.Mediators pass parameters to services</p>
</blockquote>
<p>It sounds like you’re accessing Services from your
Mediators. You can do that, if you want, but I <em>have</em> to
tell you that the recommended practice is to avoid injecting Models
and Services into your Mediators. It’s up to you, whether you
follow the rules or not:)</p>
<p>So, the better way would be:<br>
Mediators dispatch a custom event to trigger a Command that would
access a Service. The payload of that custom event can contain the
parameters needed by the Service. The Command can read that payload
and pass it to Service’s method.</p>
<blockquote>
<p>2.Services aquire parameters from injected models</p>
</blockquote>
<p>Yes, you can do that. I answered a similar question here:
<a href=
"http://knowledge.robotlegs.org/discussions/questions/995-the-optimal-aproach-fo-handling-service-events#comment_18023638">
http://knowledge.robotlegs.org/discussions/questions/995-the-optima...</a></p>
<p>Does this answer your questions?</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/185857662012-09-07T14:58:41Z2012-09-07T14:58:42ZNo subject<div><p>It does answer my question</p></div>Marektag:robotlegs.tenderapp.com,2009-10-18:Comment/185857662012-09-07T15:06:42Z2012-09-07T15:06:42ZNo subject<div><p>Cool! Then I'll mark this discussion as resolved. Please open
new threads for new issues.</p></div>Ondina D.F.