Multiple mediators listen for same event
Hi,
I have a lot (50-100 instances) of same view class. One model have data for them. And now when one of element data has been changed in model than it dispatch MyEvent.CHANGE. It's ok but now all of mediators get this event when just one of them is interested about it.
Is it correct?
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Joel Hooks on 11 Apr, 2012 06:08 PM
Assuming that each view is related to one specific data item, yes? it is fine if each mediator listens/responds to the event. What is important is that the appropriate mediator responds. You will need to figure out how to remove the ambiguity as needed via some sort of ID scheme that the event handler in the mediator will check to make sure that it is the correct responder.
Does that makes sense?
3 Posted by Amnesiac on 11 Apr, 2012 06:24 PM
Yea I can check in mediator if event is correct for that view, but isn't it strange that hundrets of mediators recive events that they don't need?
4 Posted by matt on 12 Apr, 2012 04:09 PM
if that is a concern then you could alternatively mediate the view that contains your hundreds of instances - event is then handled in one place, and your container view would then be responsible for directing the change in the model to the appropriate instance - again, via some kind of id mechanism
Ondina D.F. closed this discussion on 21 Jun, 2012 08:07 AM.