tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/849-service-dispatching-eventsRobotlegs: Discussion 2012-03-10T12:47:13Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/143691252012-03-10T11:23:49Z2012-03-10T11:23:49ZService dispatching events...<div><p>Hi Thomas:)</p>
<blockquote>
<p>When the service class has loaded the XML, dispatch its own
event notifying a ViewMediator that the XML has loaded or</p>
</blockquote>
<p>You can do that, if you don’t need a Model to work with
the loaded data.</p>
<blockquote>
<p>When the service class has loaded the XML, dispatch an event
that the model listens to and model dispatches its own event
notifying a ViewMediator that the XML has loaded</p>
</blockquote>
<p>You can do that, too, but it’s not a recommended practice
:) Models shouldn’t listen to events.<br>
You could:</p>
<ul>
<li>
<p>let the Service set the data on the Model</p>
</li>
<li>
<p>or, let the Service dispatch an event, that would trigger a
Command, that would call a method on the Model</p>
</li>
</ul>
<p>and let the Model dispatch an event with the updated data as a
payload.</p>
<blockquote>
<p>or c) Get out of the kitchen and go eat cookies neither a) or b)
makes sense Instead i propse c) Bla bla bla bla</p>
</blockquote>
<p>Diabetologists say, that eating cookies is not recommended while
having issues with your code ;)<br>
Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/143691252012-03-10T11:30:10Z2012-03-10T11:30:10ZService dispatching events...<div><p>Thanks for the reply. I really like the last approach with
Command. Why did I not think of that! It's neat, and feels more
proper than setting the data on the Model.</p>
<p>Also, thanks for the insights about reduction of cookie eating
during code issues. I shall try lemon tea, with a tad of sugar,</p>
<p>Thomas</p></div>thomas.thorstenssontag:robotlegs.tenderapp.com,2009-10-18:Comment/143691252012-03-10T12:47:13Z2012-03-10T12:47:13ZService dispatching events...<div><p>You’re welcome.<br>
Yeah, lemon tea, with a tad of sugar and ONE cookie should be
fine:)</p></div>Ondina D.F.