Multiple views controlled by one Mediator
Before I had a view class, ImageStrip
and a
corresponding ImageStripMediator
that worked just
fine.
Now I need some slightly different behaviors in two places, so I
made to subclasses of ImageStrip
:
KeyedImageStrip
and BackgroundImageStrip
and corresponding mediators for them.
I tried letting the two new mediators subclass
ImageStripMediator
since this has code I want to use.
But since this is set up to be injected with a
ImageStrip
things start to get hairy:
Error: Injector is missing a rule to handle injection into target [object KeyedImageStripMediator]. Target dependency: se.psweb.kromaki.view.menu::ImageStrip
So, how do I use subclasses of a view (with mediator) and have
mediators for those too?
And if this is completely backwards, how should I do it?
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 System on 05 Nov, 2009 02:29 PM
An internal ticket was created for this discussion
Support Staff 2 Posted by Joel Hooks on 05 Nov, 2009 02:41 PM
Perhaps using setter injection might be a better route. Then you could override the setter and [Inject(name="whatever")] on the method setting the protected value.
Support Staff 3 Posted by Shaun Smith on 05 Nov, 2009 02:57 PM
If your KeyedImageStripMediator depends on ImageStrip, you can pass it into injectViewAs when calling mapView(), like so:
mapView(KeyedImageStrip, ImageStripMediator, ImageStrip);
This will create an ImageStripMediator when a KeyedImageStrip lands on stage, but it will inject the KeyedImageStrip as an ImageStrip (which is what your Mediator actually depends on).
Does that help at all?
4 Posted by grapefrukt on 05 Nov, 2009 03:29 PM
I temporarily sidestepped the issue by duplicating the code from
ImageStripMediator
in the two new mediators. It was just a line or two, still, not very pretty. Sadly, with the way my current deadline is looming it'll have to stay that way until I've got some more tinkering time.But I think this could be solved with either method, Joels is more tailored to my specific need but i think Shauns is a bit less magical ;)
Support Staff 5 Posted by Shaun Smith on 07 Dec, 2009 02:28 PM
Hi Grapefrukt,
I believe that:
mapView(KeyedImageStrip, ImageStripMediator, ImageStrip);
would be the best solution to this problem. I'm going to close this issue for now, but please feel free to re-open it if you feel the answer to be dis-satisfactory.
Shaun Smith closed this discussion on 07 Dec, 2009 02:28 PM.
Support Staff 6 Posted by Shaun Smith on 11 Dec, 2009 08:55 PM
Actually, I think I misunderstood the core issue here. See response to:
http://knowledge.robotlegs.org/discussions/questions/21-subclassing...