tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/12983-how-to-get-a-single-instance-in-a-mxml-fileRobotlegs: Discussion 2015-06-24T13:34:06Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/372028442015-06-24T07:10:11Z2015-06-24T07:10:11ZHow to get a single instance in a mxml file<div><p>Hi,</p>
<p>The ViewProcessorMap is what you need:</p>
<pre>
<code>injector.map(SomeModel).asSingleton();
viewProcessorMap.map(SomeView).toInjection();</code>
</pre>
<p>Then you inject SomeModel into SomeView:</p>
<pre>
<code>[Inject]
public var someModel:SomeModel;</code>
</pre>
<p>Here the documentation:<br>
<a href="https://github.com/robotlegs/robotlegs-framework/tree/master/src/robotlegs/bender/extensions/viewProcessorMap#shortcut-method-for-the-most-common-case-injection-by-inspection">
https://github.com/robotlegs/robotlegs-framework/tree/master/src/ro...</a><br>
<a href="https://github.com/robotlegs/robotlegs-framework/tree/master/src/robotlegs/bender/extensions/viewProcessorMap#viewinjectionprocessor">
https://github.com/robotlegs/robotlegs-framework/tree/master/src/ro...</a></p>
<p>You can also search the forum for discussions about
viewProcessorMap.</p>
<p>Hope that helps.</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/372028442015-06-24T08:53:32Z2015-06-24T08:53:32ZHow to get a single instance in a mxml file<div><p>Thank you very much.<br>
I found <a href="https://github.com/robotlegs/robotlegs-framework/tree/master/src/robotlegs/bender/extensions/viewProcessorMap#shortcut-method-for-the-most-common-case-injection-by-inspection">
https://github.com/robotlegs/robotlegs-framework/tree/master/src/ro...</a>
"The Robotlegs 2 view map is designed to allow views to be
'processed'...". Is that mean context don't install the
ViewProcessormapExtension in RL.2?<br>
It works very good without install the ViewProcessormapExtension in
RL.2 .</p>
<p>2015-06-24</p>
<p>x8s9y</p>
<p>发件人:"Ondina D.F." <a href="mailto:tender+d9380ed7c1@tenderapp.com">tender+d9380ed7c1@tenderapp.com</a><br>
发送时间:2015-06-24 15:10<br>
主题:Re: How to get a single instance in a mxml
file [Robotlegs 2 #12983]<br>
收件人:"x8s9y"<a href="mailto:x8s9y@163.com">x8s9y@163.com</a><br>
抄送:</p></div>x8s9ytag:robotlegs.tenderapp.com,2009-10-18:Comment/372028442015-06-24T09:16:34Z2015-06-24T09:17:38ZHow to get a single instance in a mxml file<div><p>You're welcome!</p>
<blockquote>
<p>Is that mean context don't install the ViewProcessormapExtension
in RL.2?</p>
</blockquote>
<p>When you create a Context, you tell it to install the
MVCSBundle, as you did.<br>
If you're using the default MVCSBundle, the
ViewProcessormapExtension will be installed automatically. Take a
look at the MVCSBundle and see all the extensions installed by
default:<br>
<a href="https://github.com/robotlegs/robotlegs-framework/blob/master/src/robotlegs/bender/bundles/mvcs/MVCSBundle.as#L63">
https://github.com/robotlegs/robotlegs-framework/blob/master/src/ro...</a></p>
<blockquote>
<p>It works very good without install the ViewProcessormapExtension
in RL.2 .</p>
</blockquote>
<p>No, it doesn't. You can verify that by creating a custom
MVCSBundle where you comment out the ViewProcessorMapExtension.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/372028442015-06-24T10:40:53Z2015-06-24T10:40:53ZHow to get a single instance in a mxml file<div><p>yes,I use the MVCSBundle.<br>
Thank you very much.</p>
<p>2015-06-24</p>
<p>x8s9y</p>
<p>发件人:"Ondina D.F." <a href="mailto:tender+d9380ed7c1@tenderapp.com">tender+d9380ed7c1@tenderapp.com</a><br>
发送时间:2015-06-24 17:16<br>
主题:Re: How to get a single instance in a mxml
file [Robotlegs 2 #12983]<br>
收件人:"x8s9y"<a href="mailto:x8s9y@163.com">x8s9y@163.com</a><br>
抄送:</p></div>x8s9ytag:robotlegs.tenderapp.com,2009-10-18:Comment/372028442015-06-24T13:34:06Z2015-06-24T13:34:06ZHow to get a single instance in a mxml file<div><p>No problem.</p></div>Ondina D.F.