tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/8018-why-i-can-inject-a-signal-in-mediator-and-dispantch-but-not-in-viewRobotlegs: Discussion 2013-11-13T10:52:29Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/299267302013-11-12T09:56:37Z2013-11-12T09:56:37ZWhy I can inject a signal in Mediator and dispantch but not in view?<div><p>More info about how injection works:</p>
<p>See my answer here:<br>
<a href=
"http://knowledge.robotlegs.org/discussions/robotlegs-2/5766-automagic-view-injection#comment_28759520">
http://knowledge.robotlegs.org/discussions/robotlegs-2/5766-automag...</a><br>
and these:<br>
<a href=
"https://github.com/robotlegs/robotlegs-framework/wiki/Robotlegs-Internals">
https://github.com/robotlegs/robotlegs-framework/wiki/Robotlegs-Int...</a><br>
<a href=
"https://github.com/tschneidereit/SwiftSuspenders/blob/the-past/README.textile">
https://github.com/tschneidereit/SwiftSuspenders/blob/the-past/READ...</a></p>
<p>So, you need a rule (a mapping), an injection point ([Inject])
and a way to let the Injector inspect the class that needs
injection. If a view landing on the stage is not known by the
framework, it won't be processed.<br>
One way of letting the injector know that a view needs to be
inspected and processed is to use the ViewProcessorMap.<br>
There is a complex process going on behind the scenes, and I'm not
going to go into details about it. All you need to know right now
is that if you have the ViewManagerExtension,
StageObserverExtension, ViewProcessorMapExtension and
StageCrawlerExtension installed ( all of them provided by the
MVCSBundle by default), they will take care of views landing on the
stage, and if the injector finds a rule like this one :</p>
<pre>
<code>injector.map(SomeObject).asSingleton();</code>
</pre>
<p>and the ViewProcessorViewHandler has added SomeView to its list
of interestedMappings, because you did this:</p>
<pre>
<code>viewProcessorMap.map(SomeView).toInjection();</code>
</pre>
<p>SomeView will be processed and inspected,</p>
<p>and if the Injector finds an injection point:</p>
<pre>
<code>[Inject]
public var someObject:SomeObject;</code>
</pre>
<p>it will provide the dependency (SomeObject) to the view
(SomeView), the moment SomeView is added to the stage.</p>
<p>My explanation is really bad:) Hopefully, though, you'll get the
point.<br>
So if you want to inject a signal into a view by using the
viewProcessorMap, you need a mapping for the signal, as you've
already done, and this:</p>
<p>
<strong>viewProcessorMap.map(SomeView).toInjection();</strong></p>
<p>where SomeView is your view that needs the signal.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/299267302013-11-12T10:34:13Z2013-11-12T10:34:13ZWhy I can inject a signal in Mediator and dispantch but not in view?<div><p>Let me not agree with you. Your explanation is really good! :)
Thank you very much! :)</p></div>naghekyantag:robotlegs.tenderapp.com,2009-10-18:Comment/299267302013-11-12T11:09:01Z2013-11-12T11:09:01ZWhy I can inject a signal in Mediator and dispantch but not in view?<div><p>Hehe, thank you. Glad it helped.</p></div>Ondina D.F.