Singleton ViewFactory class, giving out null value
context.injector.map(StatsModel).asSingleton();
context.injector.map(XMLLoaderService).asSingleton();
context.injector.map(Factory).asSingleton(); //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Factory Class
The Factory class resides in view package and retains all the instances of views . ( inside swc.view )
I am able to inject contextView inside StatsModel class and get
a value
[Inject]
public var contextView:ContextView;
but doing the same in Factory class , gives out null .
However, it seems ok but I want to confirm, if making a singleton of Factory class ( that resides in view package ) is normal and allowed ?
After that my concern is about accessing the Factory class from view.swc ( SWC file ) . When i opened the swc file, and saw the Factory class, the [Inject] metatags were gone! They were showing as plain variables. Is that the reason i am getting null values ?
V.
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
1 Posted by vishwas.gagrani on 27 Feb, 2013 06:29 PM
ok.. i concluded with the following:
view.swc is not responsible for null value. The injectors are working fine everywhere ( In mediators, in Model singleton, except the singleton Factory class inside "View" package.
So, does that mean, unlike statsmodel ( singleton of model package) if singletons are used in view packages, the [Inject] won't work ? It's not supposed to be used there ?
Support Staff 2 Posted by Shaun Smith on 27 Feb, 2013 09:59 PM
Hi. The package should have no effect on things. Something else must be causing the issue. How do you instantiate your Factory?
Support Staff 3 Posted by Shaun Smith on 27 Feb, 2013 10:04 PM
Oh wait, I just saw this:
Maybe. The Flash IDE strips out non-standard metadata tags during compilation. You need to tell it not to by selecting "Export SWC" in the publish settings. Even if you are only using the SWF you need to select this in order to keep the metadata tags.
4 Posted by vishwas.gagrani on 28 Feb, 2013 05:32 AM
Well, first thing is i am no longer using the Flash IDE now. And second is, i checked it afterwards, and found that even after stripping the tags, it's not responsible for null values. ( Something like, it shows the meta tags stripped off... but still has the metatag information somewhere inside itself). I checked this by making another small example.
As i said, i don't instantiate the Factory class. It's a singleton, and has been mentioned in AppConfig.as ( the same way a Model class is mentioned )
It's placed in swc.view package. And is used to instantiate views as per demand via Command classes. I get the "Factory" instance in the Command classes by :
5 Posted by vishwas.gagrani on 28 Feb, 2013 05:54 AM
Ah!.. finally got it.
I was trying to get the injected contextView inside the constructor of Factory class. I am using it in the other functions, and i am getting the values. I just checked getting the value of contextView inside the constructor of Model class too.. and found the same thing "null". So, it seems that injected objects are not supposed to be used inside the constructor functions.
Anyways, got it solved.
Thnx!
V.
vishwas.gagrani closed this discussion on 28 Feb, 2013 05:54 AM.