tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/825-viewmap-and-injecting-into-viewsRobotlegs: Discussion 2012-02-29T11:23:13Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/137070622012-02-15T09:38:35Z2012-02-15T09:38:35ZViewMap and injecting into views<div><p>Hello,</p>
<p>We are developing a game, where we have a dynamic bitmap asset
repository and a configuration provider model which holds some
values required by all parts of the application.<br>
We need to access the asset repository and configuration provider
from views, so our current options are:</p>
<ol>
<li>Inject those two models into our views using ViewMap</li>
<li>Inject those two models into our views in onRegister() of the
view's mediator</li>
<li>Inject those two models into our view's mediator and pass them
to the view as parameters</li>
</ol>
<p>I see that you strongly discourage using MediatorMap and ViewMap
together. What do you suggest in this scenario?</p>
<p>Thanks,</p></div>Safa Sofuoğlutag:robotlegs.tenderapp.com,2009-10-18:Comment/137070622012-02-15T16:17:24Z2012-02-15T16:17:24ZViewMap and injecting into views<div><p>Hi Safa,</p>
<p>The suggested way to to this by stray and others - also we are
doing - is creating a command which will access your models and
dispatch an event with the data needed.<br>
Then you can on your mediator dispatch and event which will be
picked up by the command. Also your mediator should listen to the
event which will command dispatches.</p>
<p>You can then update your view with data from event. Injecting
models in to mediators or views are highly discouraged.</p>
<p>Check strays second comment on here: <a href=
"http://knowledge.robotlegs.org/discussions/questions/309-inject-model-into-the-mediator">
http://knowledge.robotlegs.org/discussions/questions/309-inject-mod...</a>.</p>
<p>Bülent Öztürk<br>
Take care.</p></div>bulupetag:robotlegs.tenderapp.com,2009-10-18:Comment/137070622012-02-15T20:44:10Z2012-02-15T20:44:11ZViewMap and injecting into views<div><p>Thank you Bülent, we are also following that approach.</p>
<p>I thought that in some exceptional cases, injecting into views
may be the only feasible solution, such as:</p>
<p><a href=
"http://knowledge.robotlegs.org/discussions/problems/149-injection-into-views">
http://knowledge.robotlegs.org/discussions/problems/149-injection-i...</a></p>
<p>What we have here is also an exceptional case. We have views
that need about a hundred assets. We also need a way to fill the
constant values and l10n-compatible strings in views.</p>
<p>Request-fulfill approach looks too heavy for these jobs, both in
terms of performance and amount of code needed.</p>
<p>So we are looking for other possible solutions.</p></div>Safa Sofuoğlutag:robotlegs.tenderapp.com,2009-10-18:Comment/137070622012-02-15T21:07:03Z2012-02-15T21:07:03ZViewMap and injecting into views<div><p>Hi again,</p>
<p>I think such a special case may need a specific behavior, what
about holding assets in a skin class with public static access,
have you ever examine stray's strategy game?</p>
<p><a href=
"https://github.com/Stray/robotlegs-demo-StrategyGame">https://github.com/Stray/robotlegs-demo-StrategyGame</a></p>
<p>Bulent</p></div>bulupe