and one more null eventdispatcher inside Actor derived class
Hi,
I wan't figure out what's happening here ... here's what's inside
my context:
var m:EpodxModule = new EpodxModule();
injector.injectInto(m);
injector.mapValue( EpodxModule,m);
then inside a model class:
public class ModulesModel extends Actor
{
private var _m:EpodxModule;
[Inject]
public function set m(value:EpodxModule):void
{
_m = value;
}
public function get m():EpodxModule
{
return _m;
}
[...]
}
Injection occurs as expected ... my m property is injected with a brand new instance of EpodxModule Class.
BUT:
m property still has a null eventDispatcher that prevents it from dispatching events for example !!! I checked by tracing it inside [PostConstruct] init function and inside others ...
There must be something wrong inside my code but honestly I can't see ...
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 Stray on 10 May, 2011 03:54 PM
Hi there,
could you post the code inside EpodxModule?
Does it definitely extend Actor?
I'm sure we can help you figure it out.
You're definitely not trying to access that eventDispatcher in the constructor? (I know you said it's in a PostConstruct function but it's worth checking).
BTW - m is a terrible name for a variable!
Stray
2 Posted by peter.bannier on 11 May, 2011 07:38 AM
Hi!
Sure m isn't a good choice !! :)
After a few hours trying to find out what's wrong, I was a bit uninspired for my variables names ...
Anyway this is the EpodxModule Class:
public class EpodxModule extends Actor
}
that's a pretty simple case isn't it ? I still can't see what's wrong ...
Thanks
Support Staff 3 Posted by Stray on 11 May, 2011 08:09 AM
Hi Peter,
when you overrode the
set eventDispatcheryou lost the[Inject]tag that was in the originalActorclass.It should be:
Ref: Line 67 of
https://github.com/robotlegs/robotlegs-framework/blob/master/src/or...
If you reinstate that then you'll probably find things work as they should - do let us know! If not then I'll help you do some deeper digging, but injection is really pretty simple:
injection point + injection rule => process through injector = happy code.
So there's a surprisingly small number of things that can go wrong.
Hopefully this fixes it!
Stray
Support Staff 4 Posted by Stray on 11 May, 2011 08:10 AM
A completely different note - is there a reason why you're using
mapValueand instantiating the instance for yourself, rather than usingmapSingleton?Stray
5 Posted by peter.bannier on 11 May, 2011 08:51 AM
Hi,
thanks for the quick reply !
That was it ! now I understand pretty well what was my mistake ...
Now I can go happy coding ... big thanks!
I was using mapValue instead of mapSingleton as I want to have the opportunity to have multiples instances if I want to ... that's the right way isn't it ?
I had a relative conceptual question :
If I want a Class to act as a manager just like my ModulesModel Class which is meant to handle multiples modules. This Class have a few modules as properties. Here, with injection, I have to instantiate those modules first inside my Context and then map them. Would it be conceptualy better to handle their instantiation inside the ModulesModel himself ?
Support Staff 6 Posted by Stray on 11 May, 2011 08:56 AM
Hi Peter,
I'm glad I asked then because the answer is that
mapClasswon't give you multiple instances (except over time, you can switch out instances).Essentially mapClass is identical to
mapSingletonOf( )except that you're controlling the creation of the concrete instance.Can I just clarify - when you talk about 'Modules' - do you mean like Robotlegs Modules (using the modular utils) - or just Flex Modules, or perhaps something totally different?
Stray
7 Posted by peter.bannier on 11 May, 2011 09:03 AM
Hi,
I was talking about something different ... it could have been anything ... just an example to picture the problem ...
thanks for your explanations and your support!
Support Staff 8 Posted by Stray on 11 May, 2011 09:08 AM
Ah - ok - no problem. Basically if you want to have multiple instances within a single context your best option is always to create a container for them.
I'll close this now - shout again if you need any more help,
Stray
Stray closed this discussion on 11 May, 2011 09:08 AM.