tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/16-brand-new-rl2-test-project-injection-issueRobotlegs: Discussion 2012-04-26T15:35:42Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/155831822012-04-26T15:15:57Z2012-04-26T15:16:51ZBrand new RL2 (test) project, injection issue<div><p>Hi Quentin,</p>
<p>The problem is that values supplied by setter injection are not
available in constructors - this is the same with RL1 - as
Swiftsuspenders has to construct the instance before it can set any
properties on it. There are two solutions:</p>
<p>1 - Move the dependencies into constructor arguments:</p>
<pre>
<code>public function RL2FirstAppConfig(mediatorMap:IMediatorMap, injector:Injector)</code>
</pre>
<p>2 - Leave them as they are and use <code>[PostConstruct]</code>
to trigger an init method:</p>
<pre>
<code>[PostConstruct]
public function init():void
{
// dependencies supplied via setter injection are now available
}</code>
</pre>
<p>The readme in the RL2 repo shows the first approach (under
Application & Module Configuration), but I'll add an example of
the second.</p>
<p>Hope that helps!</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/155831822012-04-26T15:19:58Z2012-04-26T15:19:58ZBrand new RL2 (test) project, injection issue<div><p>Oh boy!</p>
<p>I was so sure I was lost with RL2's new API that I didn't even
see this stupid error of mine!</p>
<p>Thanks for the help, app works, now.<br>
And I feel dumb, too!</p></div>Quentintag:robotlegs.tenderapp.com,2009-10-18:Comment/155831822012-04-26T15:35:12Z2012-04-26T15:35:12ZBrand new RL2 (test) project, injection issue<div><p>Haha, no worries - it happens to all of us!</p>
<p>Still, you've motivated me to update the README, so it's been
productive after all :)</p>
<p><a href=
"https://github.com/robotlegs/robotlegs-framework/blob/version2/readme.md">
https://github.com/robotlegs/robotlegs-framework/blob/version2/read...</a></p>
<p>Hopefully that will prevent others from experiencing the same
issue.</p></div>Shaun Smith