tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/2293-preload-a-viewRobotlegs: Discussion 2013-05-16T09:36:51Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/267088362013-05-06T06:23:35Z2013-05-06T06:23:37ZPreload a view<div><p>Question<br>
How do I make a view preload, as I need the event listeners to be
mapped in advance..</p>
<p>Scenario<br>
Im building a mobile application that has a list of objects as is
start screen, when an object is clicked it loads a view with all
that objects details. however, when i click the list I dispatch an
event which is mapped to a command, Inside the command the view
dispatches an event to a mediator on the main view bringing the
details view into focus, however directly event is dispatched the
model is updated with the selected object. this then causes the
model to fire an event with the object payload telling the view to
update. The problem is that that view mediator onregister() method
with the event listener isn't happening before the the model event
is dispatched so the details view isn't receiving the event with
payload.</p></div>Joshua Cavetag:robotlegs.tenderapp.com,2009-10-18:Comment/267088362013-05-06T07:20:55Z2013-05-06T07:20:55ZPreload a view<div><p>There's basically two options:</p>
<ol>
<li>
<p>The mediator retrieves the selected object from the model. Or,
if you don't want to inject models into mediators, the mediator
dispatches a request, a command picks up the selected object and
returns it to the mediator. (Either by dispatching an event, or the
mediator could've passed some kind of responder object along with
the request event, which the command populates)</p>
</li>
<li>
<p>You use the <a href=
"https://github.com/Stray/robotlegs-utilities-RelaxedEventMap">Relaxed
Event Map</a>. It allows for registering listeners <em>after</em>
an event has been dispatched, exactly to solve situations like
yours.</p>
</li>
</ol></div>creynderstag:robotlegs.tenderapp.com,2009-10-18:Comment/267088362013-05-16T09:36:50Z2013-05-16T09:36:50ZPreload a view<div><p>I'm closing this for now, if you have any more questions let us
know!</p></div>creynders