tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/1319-extension-problemRobotlegs: Discussion 2018-10-18T16:35:47Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/262102152013-04-04T13:38:34Z2013-04-04T13:38:34ZExtension Problem<div><blockquote>
<p>I mean that sometimes the Injector is mapped successfully... and
other times it is not and I get simply NULL.</p>
</blockquote>
<p>You mean an error is thrown that no mapping is found for type
Injector?<br>
Or..?</p>
<p>How do you verify that _injector is <code>null</code>? trace?
breakpoint? In the constructor?</p></div>creynderstag:robotlegs.tenderapp.com,2009-10-18:Comment/262102152013-04-04T15:17:13Z2013-04-04T15:17:13ZExtension Problem<div><p>Thank you for your reply.</p>
<p>No error is thrown from robotlegs which I think is strange.
Mainly, it happens that when I am in debug mode and have a break
point inside the constructor, I can see that the injector is null.
When I run without breakpoints and without debugging, it runs
normally... but not all the times. Only few times it will give a
null object error (because I am using the injector later on in my
class). Similarly, only few times while in debug mode, the injector
will come in normally.</p></div>mbarjawitag:robotlegs.tenderapp.com,2009-10-18:Comment/262102152013-04-04T15:22:56Z2013-04-04T15:47:29ZExtension Problem<div><p>Hi guys,</p>
<p>I tried MBarjawi’s example with
Swiftsuspenders-v2.0.0rc2.swc and it looks like the
signalCommandMap has ‘eaten’ the injector :P.</p>
<p>Without signalCommandMap the injector gets injected just
fine.<br>
But with contructor injections for both, injector and
signalCommandMap, the injector is null inside Bootstrap.</p>
<p>In fact, it affects not only the injector, but any other
dependencies provided as ctor injections.<br>
I think that behavior has to do with this bug:<br>
<a href=
"https://github.com/tschneidereit/SwiftSuspenders/pull/84">https://github.com/tschneidereit/SwiftSuspenders/pull/84</a></p>
<p>which has been fixed in the latest version ( only source
code)</p>
<p>Workaround for the version with bugs:<br>
Map and instantiate signalCommandMap in BootstrapExtension,</p>
<pre>
<code>_injector = context.injector;
_injector.map(ISignalCommandMap).toSingleton(SignalCommandMap);
_signalCommandMap = _injector.getInstance(ISignalCommandMap);
_injector.map(IBootstrap).toSingleton(Bootstrap);</code>
</pre>
<p>Or by using</p>
<pre>
<code>[PostConstruct]
public function init(injector:Injector, signalCommandMap:ISignalCommandMap):void
{</code>
</pre>
<p>Or install SignalCommandMapExtension too, and instantiate
signalCommandMap in your config.</p>
<p>[EDIT] Or just inject them instead of constructor injection in
Bootstrap.<br>
Of course, they won’t be available inside the constructor, in
this case.</p>
<pre>
<code>[Inject]
public var _injector:Injector;
[Inject]
public var _signalCommandMap:ISignalCommandMap;</code>
</pre>
<p>@MBarjawi could you try the newest version of
swiftsuspenders(source code : <a href=
"https://github.com/tschneidereit/SwiftSuspenders">https://github.com/tschneidereit/SwiftSuspenders</a>)
and tell us if that fixes your problem?</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/262102152013-04-04T16:46:12Z2013-04-04T16:46:12ZExtension Problem<div><blockquote>
<p>@MBarjawi could you try the newest version of
swiftsuspenders(source code : <a href=
"https://github.com/tschneidereit/SwiftSuspenders">https://github.com/tschneidereit/SwiftSuspenders</a>)
and tell us if that fixes your problem?</p>
</blockquote>
<p>I just tested using the latest version of swiftsuspenders... the
problem disappeared :)</p>
<p>Thanks so much,</p></div>mbarjawi