mediator is not listening to the event dispatched by the model second time.
i am working on game and i encountered a problem with the mediator not listening to the event dispatched by the model second time
basically, i have a model that dispatches an event whenever the
value 'x' is updated.
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.
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.
please can you suggest some method to fix this problem.
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Ondina D.F. on 19 Jun, 2014 03:16 PM
Hello,
I guess, you're dispatching the event from within the mediator's onRegister() before adding a listener for the event.
If so, then: first add the listener, and dispatch the event afterwards
Let me know how it goes.
Ondina
Support Staff 2 Posted by Ondina D.F. on 19 Jun, 2014 03:23 PM
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?
3 Posted by akash.07.raj on 19 Jun, 2014 03:54 PM
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.
i have debugged,
the second case is also not the issue, the event is dispatched only after the mediator has been created.
Support Staff 4 Posted by Ondina D.F. on 19 Jun, 2014 04:31 PM
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?
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?
Could you attach a bare-bone project reproducing the issue? I would take a look at it.
akash.07.raj closed this discussion on 20 Jun, 2014 05:25 AM.
akash.07.raj re-opened this discussion on 20 Jun, 2014 05:26 AM
5 Posted by akash.07.raj on 20 Jun, 2014 05:27 AM
hi,
this problem has been resolved. there were different modules and so, in the mediator i had to use a modulelistener instead of a contextlistener.
akash.07.raj closed this discussion on 20 Jun, 2014 05:28 AM.