many view inject in mediator
is possible in mediator using many inject displayobject in
RL2?
example
...
public class RealCaseMediator extends Mediator{
[Inject]
public var view1:Mc1;
[Inject]
public var view2:Mc2;
...
and using for him hitTestObject
im now get error: Injector is missing a mapping to handle injection into property...
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 Ondina D.F. on 16 Jan, 2014 02:00 PM
If you mapped a view like this:
When RealCaseView is added to the stage, RealCaseMediator will be created.
RealCaseView will be injected into RealCaseMediator, if you do this:
If you want Mc1 and Mc2 to be injected into RealCaseMediator in addition to RealCaseView, you must provide mappings for Mc1 and Mc2. Without mappings, the injector has no idea what to do.
and in your Mediator:
Also, see my answers here:
http://knowledge.robotlegs.org/discussions/robotlegs-2/5766-automag...
http://knowledge.robotlegs.org/discussions/robotlegs-2/8018-why-i-c...
Do you really need to inject Mc1 and Mc2 into RealCaseMediator? Maybe you just need to add them to RealCaseView inside the view, and dispatch a custom event from RealCaseView when Mc1 or Mc2 gets hit. RealCaseMediator should add a listener for that custom event coming from the view.
Ondina
2 Posted by transglobals on 16 Jan, 2014 02:10 PM
thanks:) i'm have little chaos with some principe of the RL:)
problem with hitTestObject i'm solved using custom event that contain "Mc2"
transglobals closed this discussion on 16 Jan, 2014 02:10 PM.
transglobals re-opened this discussion on 17 Jan, 2014 11:08 AM
3 Posted by transglobals on 17 Jan, 2014 11:08 AM
hm, i'm have still problem.
Is possible in-mediator work with many mediate displayobjects?
[Inject] other mediator not work
[Inject] displayobject where is mediated not vork
Support Staff 4 Posted by Ondina D.F. on 17 Jan, 2014 01:15 PM
Hi,
If you have a mediator like this one:
and another Mediator like this one:
If you map your views with the mediatorMap like this:
SimpleView will be injected only into SimpleMediator, but not into SomeMediator.
If you map SimpleView like this:
and you try to inject SimpleView into SomeMediator, SimpleView will be injected into SomeMediator, but the injector will complain about overriding the mappings for SimpleView, when it tries to satisfy the rule defined with mediatorMap.map(SimpleView).toMediator(SimpleMediator);.
You could unmap SimpleView and then re-map it with the mediatorMap, but that would be really cumbersome.
To avoid unmapping SimpleView and re-mapping it again, you could use the viewProcessorMap instead of the mediatorMap to create a mediator for SimpleView:
Even though you can use the trick with the viewProcessorMap, I still think that you should let a View handle the process of adding and removing child-views, instead of the Mediator.
Why do you need to inject the child-views into the mediator of the parent-view? Maybe you are overcomplicating things :) There might be a much easier solution to you problem, but you have to say more about your use case.
You'll have to read more about how injection works:) I've given you some links in my previous post. Read them again. And these ones, in case you did not find them until now:
https://github.com/robotlegs/robotlegs-framework/wiki/Robotlegs-Int...
https://github.com/robotlegs/robotlegs-framework/wiki/Best-Practices
Look at examples and other discussions on this forum.
I know, it is not easy to understand all the robotlegs concepts at once, especially if you were using other frameworks before. But, I can assure you, that robotlegs and dependency injection are a lot easier than they seem in the beginning! There are some tutorials and examples for robotlegs 1 that could help you understand the principles, which are the same in both versions of the framework. If you can't find them, I can give you the urls.
Ondina
5 Posted by transglobals on 17 Jan, 2014 02:22 PM
thanks:)
pity that links is not for RL2
transglobals closed this discussion on 20 Jan, 2014 05:37 PM.