tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/1036-mediators-binded-to-menu-items-is-that-anti-pattern-alreadyRobotlegs: Discussion 2012-09-14T07:09:03Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/185849022012-09-07T14:19:30Z2012-09-07T14:19:30ZMediators binded to menu items - is that anti-pattern already?<div><p>Hi!</p>
<p>Personally, I wouldn’t mediate each menu item.
MainMenuView should expose an API – public methods that
MainMenuMediator would access. When Model’s data arrives,
MainMenuMediator passes it to MainMenuView, which will take care of
populating the components with that data, or do whatever else is
needed. The logic (“reaching deep into the menu structure to
find suitable buttons“) that you had in your Mediator should
be in the View. When something happens in the View, it should
dispatch custom events that the mediator would re-dispatch on the
shared event dispatcher (to trigger commands, for example).</p>
<p>When you say:<br>
„ MainMenuMediator which was observing Models „, do you
mean you had the Models injected into your mediator?<br>
Perhaps you should let Commands access your Models instead.
Usually, I'm not completely against injecting Models into
Mediators, but in your case it might be a good idea to avoid this
approach, since the Mediator is getting bigger and bigger and the
logic becomes too convoluted.</p>
<p>Just my opinion :)</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/185849022012-09-07T14:25:19Z2012-09-07T14:25:19ZMediators binded to menu items - is that anti-pattern already?<div><p>@Ondina +1</p></div>neiltag:robotlegs.tenderapp.com,2009-10-18:Comment/185849022012-09-07T14:39:09Z2012-09-07T14:39:09ZMediators binded to menu items - is that anti-pattern already?<div><p>when i was saying 'observing' i meant they're listening to
models events, i hope that's ok with robotlegs practices becasue i
did a lot of stuff in that way yet :P</p>
<p>thanks a lot for that advice, ill try to figure it out</p></div>misiuoperatortag:robotlegs.tenderapp.com,2009-10-18:Comment/185849022012-09-07T14:48:18Z2012-09-07T14:48:18ZMediators binded to menu items - is that anti-pattern already?<div><blockquote>
<p>when i was saying 'observing' i meant they're listening to
models events, i hope that's ok with robotlegs practices becasue i
did a lot of stuff in that way yet :P</p>
</blockquote>
<p>haha, of course it’s ok. „MainMenuMediator which was
observing models“ triggered an alarm by BPP (best practices
police) :P</p>
<blockquote>
<p>thanks a lot for that advice, ill try to figure it out</p>
</blockquote>
<p>No problem. Just ask, we answer. (You can re-open this
discussion or start a new one)</p>
<p>Ondina</p></div>Ondina D.F.