tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/332-making-a-displayobject-eligible-for-injectionRobotlegs: Discussion 2011-11-02T15:36:47Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/77969392011-06-10T08:31:32Z2011-06-10T08:31:32ZMaking a DisplayObject eligible for injection<div><p>It's not the best practice but that is the best part about
Robotlegs you can work the way you like using only parts of the
framework that you really need.</p>
<p>About your problem. Create view instances and use injector to
map that value:<br>
injector.mapValue(YourViewClass, yourViewInstance) If you want to
use it in a Mediator make sure you do the mapping of view instances
before Mediator is created, or use
injector.getInstance(YourViewClass) when you are sure you did the
mapping</p>
<p>Cheers,<br>
Michal</p></div>Michal Wroblewskitag:robotlegs.tenderapp.com,2009-10-18:Comment/77969392011-06-10T10:08:23Z2011-06-10T10:08:23ZMaking a DisplayObject eligible for injection<div><p>Michal is spot on - the difference though is that the
mediatorMap cleans up the injections straight away when views are
set on mediators. So, you'll have those injections permanently in
the injector unless you unmap them - and that will prevent garbage
collection.</p>
<p>But... first I just want to check something out - you said:</p>
<p>"I can have like 3 view components on the main app that are too
basic to require mediation. Can I mediate them from an existing
Mediator or Command?"</p>
<p>They're too basic to require mediation, and yet you want to
mediate them? Hmm...</p>
<p>It's ok to have very light mediators with very little
functionality - that small-simple-classes workflow has many
benefits. If you need to share behaviour between mediators then
break it out into helper classes - just as you would with any
normal OO code.</p>
<p>So - Michal has given you a good working solution, but I think
you should also consider these alternatives:</p>
<ol>
<li>Mediate them directly, or</li>
<li>Mediate them through their parent view</li>
</ol>
<p>Mediator granularity is really flexible in Robotlegs, but
generally it's best to go for the simplest solution available. A
simple solution that breaks DRY beats a complex one that has
unintended consequences in my book (and then you can always DRY it
up later).</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/77969392011-06-10T10:14:36Z2011-06-10T13:37:27ZMaking a DisplayObject eligible for injection<div><p>Hi,</p>
<p>I usually use one mediator for one view. But i stumbled upon the
issue of not being able to easily inject into the application a
view that has no mediator attached. I wanted to know if this can be
done or if it's a technical restriction.</p>
<p>Thank you for the answers<br>
Ciprian</p></div>Ciprian Cabatag:robotlegs.tenderapp.com,2009-10-18:Comment/77969392011-06-10T13:20:58Z2011-06-10T13:20:58ZMaking a DisplayObject eligible for injection<div><p>Hi Ciprian - robotlegs <em>can</em> do almost anything - it
turns into a robot helicopter if you know the secret key
combination ;)</p>
<p>So - do you want to describe your use case and we'll give you a
direction on the best route to take to achieve it?</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/77969392011-11-02T15:36:47Z2011-11-02T15:36:47ZMaking a DisplayObject eligible for injection<div><p>Hi Ciprian,<br>
If you want to continue this discussion, feel free to reopen it.
I’m closing the thread now.<br>
Please open new threads for new issues.<br>
Thank you.<br>
Ondina</p></div>Ondina D.F.