Multiple mediators listen for same event

Amnesiac's Avatar

Amnesiac

11 Apr, 2012 05:45 PM

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?

  1. Support Staff 2 Posted by Joel Hooks on 11 Apr, 2012 06:08 PM

    Joel Hooks's Avatar

    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?

  2. 3 Posted by Amnesiac on 11 Apr, 2012 06:24 PM

    Amnesiac's Avatar

    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?

  3. 4 Posted by matt on 12 Apr, 2012 04:09 PM

    matt's Avatar

    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

  4. Ondina D.F. closed this discussion on 21 Jun, 2012 08:07 AM.

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