tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/995-the-optimal-aproach-fo-handling-service-eventsRobotlegs: Discussion 2012-09-14T07:08:38Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/180202292012-08-14T17:09:37Z2012-08-14T17:09:37ZThe optimal aproach fo handling service events<div><p>Hi misiuoperator,</p>
<blockquote>
<p>at SaveProjectCommand? –</p>
</blockquote>
<p>You can do that.</p>
<blockquote>
<p>maybe at ProjectService? –</p>
</blockquote>
<p>If you don’t need a reusable Service, you can inject the
Model directly into it.</p>
<p>If, on the other hand, you need to use the same Service
elsewhere and you want to keep it loosely coupled and having just
one responsibility, you shouldn’t inject the Model into
it.</p>
<p>In your Service.onSaveProjectResult() you can dispatch a custom
event that triggers a Command that updates the Model. When its data
changes, the Model dispatches an event, and interested Mediators
would listen for it.</p>
<blockquote>
<p>I'm sending query to make remote service save my project, when
it's done service shall respond 'ok' message to let my model
update.</p>
</blockquote>
<p>Do you need to update only the projectModel.iSsaved in your
Model, or is there more data that needs to be processed and sent to
other parts of your application? Do you need to store iSsaved in
your Model?</p>
<p>If you <em>just</em> need to let one or more Mediators know that
the data has been saved, and they don’t need anything else
from the Model, you can let the Mediator(s) listen for an event
dispatched in your Service.onSaveProjectResult.</p>
<p>I hope that this is going to help you.<br>
Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/180202292012-09-07T13:37:58Z2012-09-07T13:37:58ZThe optimal aproach fo handling service events<div><p>Thank you very much, i thought i send my thanks to you, but now
i can see i didn't publish it somehow.</p></div>misiuoperatortag:robotlegs.tenderapp.com,2009-10-18:Comment/180202292012-09-07T14:20:25Z2012-09-07T14:20:25ZThe optimal aproach fo handling service events<div><p>You’re welcome!!</p></div>Ondina D.F.