tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/572-model-is-not-being-listened-toRobotlegs: Discussion 2012-07-10T03:40:12Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/160195012012-05-16T07:10:42Z2012-05-16T07:19:55Zmodel is not being listened to<div><p>Hey Chris :)</p>
<p>There is a very long discussion on this topic:</p>
<p><a href=
"http://knowledge.robotlegs.org/discussions/problems/353-mediator-cant-hear-an-event">
http://knowledge.robotlegs.org/discussions/problems/353-mediator-ca...</a></p>
<p>The short answer:<br>
The Command, GetCommand, runs <strong>before</strong>
ThinSliceMediator.onRegister(), thus the Mediator can’t hear
the event dispatched by the Model.</p>
<p>To make sure the Mediator is ready, you can:<br>
-dispatch a custom event <em>after</em>
<strong>FlexEvent.APPLICATION_COMPLETE</strong> has fired</p>
<p>-or within the ThinSliceMediator.onRegister() after mapping the
event</p>
<p>In your Context.startup():<br>
contextView.addEventListener(FlexEvent.APPLICATION_COMPLETE,
onApplicationComplete);</p>
<p>instead of<br>
commandMap.mapEvent(ContextEvent.STARTUP_COMPLETE, GetCommand,
ContextEvent);</p>
<p>Then in the handler:<br>
protected function onApplicationComplete(event:Event):void<br>
{</p>
<p>dispatchEvent(new
ThinSliceModelEvent(ThinSliceModelEvent.GET_MODELS_DATA));<br>
}</p>
<p>One more thing. I know it’s just a test application, but
even so it would be better to use the recommended mvcs packages, to
avoid possible naming conflicts.</p>
<p>Ondina</p></div>Ondina D.F.