injectViewAs in RL2
we are currently trying to migrate from RL1 to RL2 to evaluate a possible Haxe port of our games.
In RL1 we make extensive use of injectViewAs, for example: mediatorMap.mapView(BuyPopup, BuyPopupMediator, IPopup);
This allows us to have BuyPopupMediator extend BasePopupMediator that handles all basic Popup code. The view is injected into BasePopupMediator as IPopup.
What is the equivalent in RL2 to inject a view as a specific subclass in the mediator? There seems to be no injectViewAs functionality. Currently, we are mapping our mediators like this:
This fails, because BuyPopupMediator tries to inject an instance of IPopup.
Thanks in advance,
Comments are currently closed for this discussion. You can start a new one.
|?||Show this help|
|ESC||Blurs the current field|
|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 10 Aug, 2017 06:46 AM
Please take a look at these answers:
robotlegs documentation on github:
Let me know whether it's what you are looking for or not.
2 Posted by Ruben on 10 Aug, 2017 10:12 AM
thanks for your swift response! This seems to work quite well, thank you. However I have one problem now: In Robotlegs 1 we were doing this:
In Robotlegs 1 this results in all Popups having exactly one Mediator. Only popups that would not have a hit against one of the specific combinations would receive a BasePopupMediator. (Note we were using an InterfaceMediatorMap I found online somwhere). So every popup ends up with exactly one Mediator. Only popups that dont have their specific mediator defined will receive a BasePopup Mediator.
I am now trying to recreate the behavior in Robotlegs 2 like this:
However Robotlegs 2 does not seem to stop when the first Mediator was created, so I end up with LoginPopup having 2 mediators: A LoginPopupMediator and a BasePopupMediator.
Is there a way to make sure that only the first mediator is used? We have hundreds of specific popup classes, so using .noneOf() would seem overly complex and hard to maintain.
Thanks in advance,
Support Staff 3 Posted by Ondina D.F. on 10 Aug, 2017 03:41 PM
No problem, Ruben.
You shouldn't try to map the BasePopupMediator.
I would create a derived class, let's say, DerivedPopupMediator, that would simply extend BasePopupMediator. It would be responsible for all IPopup views with the exception of LoginPopUp.
Does this help?
Support Staff 4 Posted by Ondina D.F. on 11 Aug, 2017 07:03 AM
Maybe even better than the previous solution:
Let all views that you don't want to be mediated by the DerivedPopupMediator implement yet another interface, a dummy interface, IExceptionView, without functionality. LoginPopup view would implement IPopup and IExceptionView.
Ondina D.F. closed this discussion on 17 Nov, 2017 11:39 AM.