How to get a single instance in a mxml file
Use Flex module:
1.Create a module, add ContextBuilderTag in Declarations tag:
<fx:Declarations>
<mxml:ContextBuilderTag>
<mvcs:MVCSBundle/>
<config:ModelManagerConfig/>
</mxml:ContextBuilderTag>
</fx:Declarations>
2.config:ModelManagerConfig is my custom config: I create a ModelManagerModel single like this:
inject.map(ModelManagerModel).asSingleton();
3.I need to use the ModelManagerModel in a mxml file, but this mxml not mediator.
so how to get the ModelManagerModel ?
- ModelManager.mxml 1.3 KB
- ModelManagerConfig.as 1.64 KB
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Ondina D.F. on Jun 24, 2015 @ 07:10 AM
Hi,
The ViewProcessorMap is what you need:
Then you inject SomeModel into SomeView:
Here the documentation:
https://github.com/robotlegs/robotlegs-framework/tree/master/src/ro...
https://github.com/robotlegs/robotlegs-framework/tree/master/src/ro...
You can also search the forum for discussions about viewProcessorMap.
Hope that helps.
Ondina
2 Posted by x8s9y on Jun 24, 2015 @ 08:53 AM
Thank you very much.
I found https://github.com/robotlegs/robotlegs-framework/tree/master/src/robotlegs/bender/extensions/viewProcessorMap#shortcut-method-for-the-most-common-case-injection-by-inspection "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?
It works very good without install the ViewProcessormapExtension in RL.2 .
2015-06-24
x8s9y
发件人:"Ondina D.F." <[email blocked]>
发送时间:2015-06-24 15:10
主题:Re: How to get a single instance in a mxml file [Robotlegs 2 #12983]
收件人:"x8s9y"<[email blocked]>
抄送:
Support Staff 3 Posted by Ondina D.F. on Jun 24, 2015 @ 09:16 AM
You're welcome!
When you create a Context, you tell it to install the MVCSBundle, as you did.
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:
https://github.com/robotlegs/robotlegs-framework/blob/master/src/ro...
No, it doesn't. You can verify that by creating a custom MVCSBundle where you comment out the ViewProcessorMapExtension.
4 Posted by x8s9y on Jun 24, 2015 @ 10:40 AM
yes,I use the MVCSBundle.
Thank you very much.
2015-06-24
x8s9y
发件人:"Ondina D.F." <[email blocked]>
发送时间:2015-06-24 17:16
主题:Re: How to get a single instance in a mxml file [Robotlegs 2 #12983]
收件人:"x8s9y"<[email blocked]>
抄送:
Support Staff 5 Posted by Ondina D.F. on Jun 24, 2015 @ 01:34 PM
No problem.
Ondina D.F. closed this discussion on Jun 24, 2015 @ 01:34 PM.