tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/453-child-view-mediator-isnt-registered-in-time-for-certain-thingsRobotlegs: Discussion 2012-01-05T12:59:01Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/120098022011-12-09T17:27:52Z2011-12-09T17:27:52ZChild view mediator isn't registered in time for certain things<div><p>So I gues basically my questions is what is a best practice for
making sure all child view mediators of a parent view are
registered before I do anything that affects all child views?</p></div>kamcknigtag:robotlegs.tenderapp.com,2009-10-18:Comment/120098022011-12-09T17:33:53Z2011-12-09T17:33:53ZChild view mediator isn't registered in time for certain things<div><p>If you map your views so that you map the deepest nested first,
and the closest to the surface last (when you do
mediatorMap.mapView...) you should be fine.</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/120098022011-12-09T17:34:36Z2011-12-09T17:34:36ZChild view mediator isn't registered in time for certain things<div><p>Hi!</p>
<p>One solution would be to let ChildBMediator dispatch an event in
its onRegister(). ViewAMediator would register a listener for it
and let ChildA render the data in the event’s handler
method.</p>
<p>Or have a look at RelaxedEventMap. I'll provide the link.</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/120098022011-12-09T17:43:06Z2011-12-09T17:44:41ZChild view mediator isn't registered in time for certain things<div><p>Stray, that didn't work, the parent mediator is still registered
first. One thing if it matters, childB is actually an ancestor of
the parent. so it's actually like what is displayed below. Where
ChildC is actually the one being mediated that isn't catching the
events. I just simplified it.</p>
<p>So in this example, ViewA, and ChildC have mediators. So in
ViewA's mediator's onRegister() I tell ChildA to update, child a
updates and diispatches an event that I want ChildC's mediator to
catch. But ChildC's mediator hasn't been registered yet. I have put
ChildC's mediatorMap entry first in the list.</p>
<pre>
<code>ViewA
-ChildA
-ChildB
-ChildC</code>
</pre></div>kamcknigtag:robotlegs.tenderapp.com,2009-10-18:Comment/120098022011-12-09T17:45:32Z2011-12-09T17:45:32ZChild view mediator isn't registered in time for certain things<div><p>Ondina,</p>
<p>I have heard of the RelaxedEventMap, but not used it, I did not
see a link in your post though.</p>
<p>Kyle</p></div>kamcknigtag:robotlegs.tenderapp.com,2009-10-18:Comment/120098022011-12-09T18:03:46Z2011-12-09T18:03:46ZChild view mediator isn't registered in time for certain things<div><p>Ondina,</p>
<p>The RelaxedEventMap solution worked, thank you!</p>
<p>Stray, is there anything else I might be missing? I'd rather fix
it without having to... I dunno if using the relaxed map is
"cheating", but if it can be done without extras then I'd like
to.</p></div>kamcknigtag:robotlegs.tenderapp.com,2009-10-18:Comment/120098022011-12-09T18:08:01Z2011-12-09T18:08:01ZChild view mediator isn't registered in time for certain things<div><p>If you really do have a race condition then that's what I built
the RelaxedEventMap for :)</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/120098022011-12-09T18:08:41Z2011-12-09T18:08:41ZChild view mediator isn't registered in time for certain things<div><p>Then that's what I'll stick with :) Thanks!</p></div>kamcknig