Problems with Mediator mapping when using multiple inheritance
Hey!
I'm using RL for quite some time now and recently switched to RL 2.0.0. It all worked nicely until things got a little bit more complex.
I'm developing a structured mobile app with several Pages and Buttons all deriving from a single BaseItem class. The BaseItem class has a set data function which is called by the BaseMediator with data from the server. The Mediator knows which data to fetch, so I can rely on a single Mediator to do all the loading work.
The structure is about as follows:
Button1 extends BaseItem
Button2 extends Button1
Page1 extends BaseItem
Page2 extends Page1
MainPage extends Page1
In RobotLegs 1.5.2 I would have used these mappings for every element which worked just fine:
mediatorMap.mapView(MainPage, BaseMediator, BaseItem);
mediatorMap.mapView(Button2, BaseMediator, BaseItem);
mediatorMap.mapView(Page2, BaseMediator, BaseItem);
in RL 2 however, there is no parameter for a BaseClass so
mediatorMap.map(MainPage).toMediator(BaseMediator);
tells me Injector is missing a mapping to handle injection into property "view" of object "[object BaseMediator]"...
So i changed it to BaseItem and hoped the built-in TypeMatcher will do it correctly
mediatorMap.map(BaseItem).toMediator(BaseMediator);
but it throws an error in VigilanceExtension stating **Injector mapping override for type [class BaseItem] with name (sic!) **
Have I missed something trivial here? Or is there an error in
SwiftSuspenders (The 2nd case let's me think of this)?
I downloaded the latest package from github using the included
Swiftsuspenders-v2.0.0rc3.swc
Attached you'll find my code.
Developing with Intellij Idea 12
Pure ActionScript for Mobile
with Flex SDK 4.6.0, Air 4.0 beta
(but didn't work on regular web project either)
Thx, Reinbert
- src.zip 4.16 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
1 Posted by email on 24 Feb, 2014 05:14 PM
As often, I eventually found a solution myself after posting it online. Still, it may help others.
Using
mediatorMap.map(BaseItem).toMediator(BaseMediator); deactivating the VigilanceExtension and setting LogLevel to WARN in the Bundle removes all unwanted output.
However, I don't think that using above mapping should produce a warning at all.
Support Staff 2 Posted by Ondina D.F. on 25 Feb, 2014 08:42 AM
Hey Reinbert,
Your first post got stuck into the spam filter of the forum. I've restored it.
This should work just fine:
mediatorMap.map(BaseItem).toMediator(BaseMediator);
I'll take a look at your attached project and report back my findings
Ondina
Support Staff 3 Posted by Ondina D.F. on 25 Feb, 2014 10:22 AM
I looked at your classes.
You're adding child views inside of the set data() method.
I added a handler for (each) view's ADDED_TO_STAGE, where I added their child-views. (Note: I was overriding an addedtostage handler of the BaseView in the derived views)
That seems to work. Each view has its own BaseMediator.
The mapping is : mediatorMap.map(BaseItem).toMediator(BaseMediator);
and [Inject] public var view:BaseItem; is injected into BaseMediator
Try it out and let me know how it goes.
Ondina
Ondina D.F. closed this discussion on 11 Mar, 2014 08:49 AM.