PureMVC
Home
About
Code
Docs
FAQ
Forums
News
Showcase
Contact
Jobs
Welcome,
Guest
. Please
login
or
register
.
May 19, 2013, 04:57:49 AM
News:
ATTENTION: Spambots must die! Humans must visit
http://contact.futurescale.com
to request forum access.
PureMVC Architects Lounge
PureMVC Manifold
Port to AS3
Standard Version
Register Mediator
Pages: [
1
]
« previous
next »
Author
Topic: Register Mediator (Read 7897 times)
saulo.brust
Courseware Beta
Newbie
Posts: 2
Register Mediator
«
on:
May 29, 2009, 07:34:17 AM »
Hey PureMVC Coders,
What's the best place to register a Mediator? In a Command, facade method, in the View Component or other place?
I don't see a reason to create a command just register a mediator. I prefer to register in the View Component, at creationComplete handler. I guess it is more simple and straight to the point!
I'm doing this, inside the View Component:
private function init():void
{
facade.registerMediator( new UserAddMediator(this) );
}
Is it right?
Thanks,
Saulo
«
Last Edit: May 29, 2009, 12:36:28 PM by saulo.brust
»
Logged
Tekool
Sr. Member
Posts: 196
Re: Register Mediator
«
Reply #1 on:
May 29, 2009, 03:11:20 PM »
No it is not ok because the PureMVC paradigm is that views must don't know their mediators. By doing this, your view knows its mediator. You better have to use the startup command as in the EmployeeAdmin Startup command (
http://puremvc.org/pages/demos/AS3/Demo_AS3_Flex_EmployeeAdmin/srcview/source/org/puremvc/as3/demos/flex/employeeadmin/controller/StartupCommand.as.html
). It's only one line of code and it's quite more logical.
Logged
saulo.brust
Courseware Beta
Newbie
Posts: 2
Re: Register Mediator
«
Reply #2 on:
June 09, 2009, 04:45:49 AM »
I understood the reason for must not register a Mediator at view component. This makes sense at PureMVC.
But, it's very strange create a command just to register a Mediator. I think we can create a command for register many Mediators.
In my case, I have 3 Proxys and 10 Mediators. The business logics I implement in 3 Commands.
Thanks for help!
Logged
puremvc
Global Moderator
Hero Member
Posts: 2790
Re: Register Mediator
«
Reply #3 on:
June 09, 2009, 05:42:42 AM »
Usually we have a StartupCommand that registers the initially required Proxies and Mediators all in one place. That gets kicked off from ApplicationFacade.startup().
-=Cliff>
Logged
Mirux
Jr. Member
Posts: 11
Re: Register Mediator
«
Reply #4 on:
September 03, 2009, 07:11:28 AM »
Hello,
I just got started with PureMVC, I think it is great but I have some doubts.
I've got a MacroCommand which Execute two subcommands which are: SetupModelCommand & SetupViewCommand.
In SetupModelCommand I register the required proxies and in SetupViewCommand I register the required Mediators, BUT.
I have a mediator called: AppControlBarMediator, which I can't initialize here, because it is a Mediator of a component which is a child of a VIEW (viewComponent), which has not been created yet because it is another state of my application.
I have two states for my application: LoginView and MainView.
So I thought for a minute and the only logic solution I found to this is, create a Mediator for my MainView, and on the "creationComplete" event of this view, send a notification to the MainViewMediator, in WHICH, I'd register the Mediator for the AppControlBar.
My doubt is, is there any "better practice" for where to register mediators or proxies? I read proxies can be retrieved from Mediators and Commands, but it is more proper to register them in the command.
I'd like to hear some opinions about this. I like following conventions and keep the code in order, so that's why I stumble on these silly details.
Shall Mediators be registered anywhere or is there an order? Is it recommended to unregister Mediators or Proxies if I am not going to use them anymore? I know it sounds logical but I'd like to hear opinions.
Logged
Jason MacDonald
Sr. Member
Posts: 243
Re: Register Mediator
«
Reply #5 on:
September 03, 2009, 09:48:50 AM »
If I understand your structure correctly, you have an AppControlBar that is a child component of another that has some kind of deferred instantiation, right? If this is the case, then why not just have the parent components mediator create and register the child [AppControlBar] mediator if/when the component becomes avalaible?
It's quite appropriate to have mediators register other mediators for child components. See the
Hello Flash
demo for an nice simple example of mediators registering other mediators for children.
«
Last Edit: September 03, 2009, 09:52:04 AM by Jason MacDonald
»
Logged
Mirux
Jr. Member
Posts: 11
Re: Register Mediator
«
Reply #6 on:
September 03, 2009, 09:54:23 AM »
Good, that's what I wanted to hear, either a confirmation of what I was thinking or a different view.
I thought that was the most logical way to do it:
Quote
It's quite appropriate to have mediators register other meditros for it's components children
I just wasn't sure if mediators registering other mediators was proper or okay with the puremvc paradigma/conventions.
Logged
puremvc
Global Moderator
Hero Member
Posts: 2790
Re: Register Mediator
«
Reply #7 on:
September 04, 2009, 07:00:02 AM »
Yes this is fine. Often times the only mediator registered in the view preparation phase of startup will be the mediator for the application itself. Then the application mediator will, in its onRegister method, register the mediators for the application's top level mediated view components. Sometimes those view components will instantiate children at a later time. Usually it is the mediator of those view components that will register the mediators for their deferred children, by listening for their creation events.
Think about it this way, the mediator should be the only touchpoint in the application that 'knows' enough about a view component to wrap a mediator around one of its children. A command that would reach way down into the application to do this would be assuming too much knowledge about the structure of the app or view component, breaking its encapsulation and making it more difficult to refactor later.
Also see the Slacker AS3/Flex demo for more on the handling of deferred instantiation.
-=Cliff>
Logged
Mirux
Jr. Member
Posts: 11
Re: Register Mediator
«
Reply #8 on:
September 04, 2009, 07:32:09 AM »
Thank you Cliff.
Logged
puremvc
Global Moderator
Hero Member
Posts: 2790
Re: Register Mediator
«
Reply #9 on:
August 03, 2010, 05:56:51 AM »
This is where deferred instantiation of view components puts a kink in the view prep. Have a look at the Slacker Flex demo (and read the article under News on this site that describes it). There is also a FAQ entry about deferred instantiation.
-=Cliff>
Logged
Pages: [
1
]
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Announcements and General Discussion
-----------------------------
=> General Discussion
=> Getting Started
=> Architecture
=> Public Demos, Tools and Applications
===> Fabrication
-----------------------------
PureMVC Manifold
-----------------------------
=> Port Authority
===> Contributor Central
===> Client Side
===> Server Side
=> Port to AS2
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to AS3
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to ColdFusion
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to C++
===> MultiCore Version
=====> Demos and Utils
=====> Bug Report
=> Port to CSharp
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to Dart
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to Haxe
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to Java
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to JavaScript
===> Demos and Utils
===> Native JS Branch
=====> Bug Report
===> PrototypeJS Branch
=====> Bug Report
===> Objs Branch
=====> Bug Report
===> MooTools Branch
=====> Bug Report
===> ExtJS Branch
=====> Bug Report
=> Port to Objective C
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to Perl
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to PHP
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to Python
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to Ruby
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to TypeScript
===> Standard Version
=====> Bug Report
=====> Demos and Utilities
===> MultiCore Version
=====> Bug Report
=====> Demos and Utilities
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Powered by SMF 1.1.11
|
SMF © 2006-2007, Simple Machines LLC
Loading...
Copyright © 2006-2008 Futurescale, Inc.