tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/5772-mediator-is-not-listening-to-the-event-dispatched-by-the-model-second-timeRobotlegs: Discussion 2014-06-20T16:06:20Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/334672692014-06-19T14:04:11Z2014-06-19T14:04:12Zmediator is not listening to the event dispatched by the model second time.<div><p>i am working on game and i encountered a problem with the
mediator not listening to the event dispatched by the model second
time</p>
<p>basically, i have a model that dispatches an event whenever the
value 'x' is updated.<br>
when the view initializes, the view mediator dispatches an event on
being registered. this flow will finally update the value 'x' in
the model. the model will then dispatch an event that the value has
been updated with the new value. this event is listened
(contextlistener) in the original mediator that dispatched the
event in the first place. this mediator will then update the
view.<br>
when i come back to that view the second time, the event is
dispatched by the model( i confirmed this) but the mediator is not
listening to it.</p>
<p>please can you suggest some method to fix this problem.</p></div>akash.07.rajtag:robotlegs.tenderapp.com,2009-10-18:Comment/334672692014-06-19T15:16:06Z2014-06-19T15:16:06Zmediator is not listening to the event dispatched by the model second time.<div><p>Hello,</p>
<p>I guess, you're dispatching the event from within the mediator's
onRegister() <strong>before</strong> adding a listener for the
event.<br>
If so, then: <strong>first add the listener</strong>, and dispatch
the event afterwards</p>
<p>Let me know how it goes.</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/334672692014-06-19T15:23:48Z2014-06-19T15:23:48Zmediator is not listening to the event dispatched by the model second time.<div><blockquote>
<p>when i come back to that view the second time, the event is
dispatched by the model( i confirmed this) but the mediator is not
listening to it.</p>
</blockquote>
<p>Could it be that the view has been removed from stage,
intentionally, or through re-parenting? Are there some transition
effects going on in your view, or a change of states, or anything
else that could cause re-parenting?</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/334672692014-06-19T15:54:16Z2014-06-19T15:54:16Zmediator is not listening to the event dispatched by the model second time.<div><p>in the mediator class, i have written a onMediatorRegistered()
function that is executed after adding all the listeners. the event
is dispatched in the onMediatorRegistered() function.</p>
<p>i have debugged,<br>
the second case is also not the issue, the event is dispatched only
after the mediator has been created.</p></div>akash.07.rajtag:robotlegs.tenderapp.com,2009-10-18:Comment/334672692014-06-19T16:31:53Z2014-06-19T16:31:53Zmediator is not listening to the event dispatched by the model second time.<div><p>Well, without seeing some code, I'm still thinking that there
are some race condition issues in your code. Maybe some
asynchronous process (service call) ? What's the exact workflow in
your scenario?</p>
<blockquote>
<p>the second case is also not the issue, the event is dispatched
only after the mediator has been created.</p>
</blockquote>
<p>Do you mean that the mediator has been destroyed and created
again, because the view has been removed from/added to the stage?
If yes, then maybe the model dispatches the event before the
mediator had a chance to be created, and thus it is not able to add
a listener for the event?</p>
<p>Could you attach a bare-bone project reproducing the issue? I
would take a look at it.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/334672692014-06-20T05:27:31Z2014-06-20T05:27:31Zmediator is not listening to the event dispatched by the model second time.<div><p>hi,<br>
this problem has been resolved. there were different modules and
so, in the mediator i had to use a modulelistener instead of a
contextlistener.</p></div>akash.07.raj