Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Registering Mediators Dynamically  (Read 10461 times)
mikebritton
Full Member
***
Posts: 42


View Profile Email
« on: November 20, 2008, 06:07:05 »

I have an app that has two modes, "default" and "custom".  Default mode means views use a standard set of components; custom mode means views have been customized and should load images for their UI.

Because of this, my views differ significantly enough to warrant creating a mediator for each.  The alternative would introduce a lot of messy conditional logic to the views, which is something I want to keep at a minimum.

So here goes: I have a command that registers these mediators based on boolean flags set in my proxies.  These booleans tell the app whether certain views are "custom" or "default".  How do I refer to the base app, where the views have been instantiated, from my command?

One approach is to store a reference to the main application on the facade, and fire a method on the facade when I'm ready to set the mediators dynamically.

In ApplicationFacade:

:
public function startup( app:VODPlayer ):void
{
this.app = app;
sendNotification( STARTUP, app );
}

public function get app():VODPlayer { return __app; }
public function set app(value:VODPlayer):void { __app = value; }

In the Command:

:
var app:VODPlayer = ApplicationFacade(facade).app;

This doesn't feel like a good technique.  Has anyone come up something more elegant?  Am I missing something simple and obvious?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: November 20, 2008, 10:26:37 »

Why are you stashing a ref to the app on the facade rather than passing it to an ApplicationMediator?

-=Cliff>
Logged
mikebritton
Full Member
***
Posts: 42


View Profile Email
« Reply #2 on: November 20, 2008, 11:37:54 »

Uh....

Because I didn't think of that.  Maybe I should avoid coding when I haven't had my coffee.

Thanks Cliff!
Logged
Pages: [1]
Print