Closed reduxdj closed 12 years ago
I believe this is how you map views to mediators in Robotlegs 2.
mediatorMap.map(MyAppView).toMediator(MyAppViewMediator)
What if it is already instantied?
On Sun, Sep 9, 2012 at 1:50 PM, Peter Keating notifications@github.comwrote:
I believe this is how you map views to mediators in Robotlegs 2.
mediatorMap.map(MyAppView).toMediator(MyAppViewMediator)
— Reply to this email directly or view it on GitHubhttps://github.com/robotlegs/robotlegs-framework/issues/94#issuecomment-8406191.
If it is already (by 'it' I assume your referring to the view) and you have access to the instance then the code below will work.
mediatorMap.map(MyAppView).toMediator(MyAppViewMediator);
mediatorMap.mediate(instanceOfMyAppView);
Ok, and how do I access my 'it' from the context, I am passing it into configure, but I'd like to be able to access it in the config?
context = new Context()
.extend(MVCSBundle)
.configure(Config, this);
Thanks, Your other solution works
On Mon, Sep 10, 2012 at 4:36 AM, Peter Keating notifications@github.comwrote:
If it is already (by 'it' I assume your referring to the view) and you have access to the instance then the code below will work.
mediatorMap.map(MyAppView).toMediator(MyAppViewMediator); mediatorMap.mediate(instanceOfMyAppView);
— Reply to this email directly or view it on GitHubhttps://github.com/robotlegs/robotlegs-framework/issues/94#issuecomment-8417141.
You could pass it into your config either through the constructor or a property using the code below.
context = new Context()
.extend(MVCSBundle)
.configure(new Config(instanceOfView), this);
or
var config = new Config();
config.view = instanceOfView;
context = new Context()
.extends(MVCSBundle)
.configure(config, this);
However I must ask what the scenario is that the view exists before the RL context is defined?
It's the root displayObject of the application, it has to be created before anything else.
On Mon, Sep 10, 2012 at 10:29 AM, Peter Keating notifications@github.comwrote:
You could pass it into your config either through the constructor or a property using the code below.
context = new Context() .extend(MVCSBundle) .configure(new Config(instanceOfView), this);
or
var config = new Config(); config.view = instanceOfView;
context = new Context() .extends(MVCSBundle) .configure(config, this);
However I must ask what the scenario is that the view exists before the RL context is defined?
— Reply to this email directly or view it on GitHubhttps://github.com/robotlegs/robotlegs-framework/issues/94#issuecomment-8424681.
Okay, well I think you can use the code above and that will work. I just tested the code in a sample application that I have created for RL2 (https://github.com/peterkeating/todolist-example) and it works.
In your config you will need something like this.
mediatorMap.map(RootDisplayObject).toMediator(RootDisplayObjectMediator);
mediatorMap.mediate(instanceOfRootDisplayObject);
Thanks
mediatorMap.mapView( MyAppView, MyAppViewMediator );