robotlegs / robotlegs-framework

An ActionScript 3 application framework for Flash and Flex
https://robotlegs.tenderapp.com/
MIT License
966 stars 261 forks source link

How do I map my mainView 2.0, there's no examples or a way that I can tell? #94

Closed reduxdj closed 12 years ago

reduxdj commented 12 years ago

mediatorMap.mapView( MyAppView, MyAppViewMediator );

peterkeating commented 12 years ago

I believe this is how you map views to mediators in Robotlegs 2.

  mediatorMap.map(MyAppView).toMediator(MyAppViewMediator)
reduxdj commented 12 years ago

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.

peterkeating commented 12 years ago

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);
reduxdj commented 12 years ago

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.

peterkeating commented 12 years ago

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?

reduxdj commented 12 years ago

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.

peterkeating commented 12 years ago

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);
reduxdj commented 12 years ago

Thanks