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
PureMVC Architects Lounge
PureMVC Manifold
Port to AS3
MultiCore Version
Page 'redirect' in Mediator or Command?
Pages: [
1
]
« previous
next »
Author
Topic: Page 'redirect' in Mediator or Command? (Read 14016 times)
jlahr
Jr. Member
Posts: 19
Page 'redirect' in Mediator or Command?
«
on:
December 29, 2009, 02:44:40 »
If I have a LoginFormMediator that listens for a LOGIN_SUCESSFUL notification from a remote proxy, should I load the homepage.swf in the LoginFormMediator's notificationHandler? Or, in the interest of code reuse, create a Redirect command that handles the loading of external SWFs and pass it whatever it needs?
Is this something the PureMVC has a philosophy on or am I starting to get too implementation-specific?
Thanks.
Logged
jlahr
Jr. Member
Posts: 19
Re: Page 'redirect' in Mediator or Command?
«
Reply #1 on:
December 29, 2009, 03:03:11 »
Thinking more about this, I'm tending towards handling this in a StageMediator (which I'm just now starting to see purpose of) because it's dealing with the entire stage as a View Component rather than just a subsection such as a LoginForm.
Even still, I'm not sure if the StageMediator should manage redirects over a Command.
Logged
hesten
Sr. Member
Posts: 52
Re: Page 'redirect' in Mediator or Command?
«
Reply #2 on:
December 29, 2009, 03:39:26 »
I don't think you would want to handle any loading of swf files in any mediator. That should probably be handled by a view component.
Mediators shouldn't contain logic as such, except as a "filter" on notifications, that tells some view component what to do upon that specific notification.
Logged
jlahr
Jr. Member
Posts: 19
Re: Page 'redirect' in Mediator or Command?
«
Reply #3 on:
December 29, 2009, 03:46:19 »
I feel like a View Component would be a bad choice because, in my understanding, they are to have the least amount of logic of any component in the framework. They just package data and hand it of the Mediator.
I feel like a single mediator that did nothing but listen for redirect notifications and accessed the stage accordingly seems like the way to go.
Logged
hesten
Sr. Member
Posts: 52
Re: Page 'redirect' in Mediator or Command?
«
Reply #4 on:
December 30, 2009, 01:12:37 »
I'm certainly no PureMVC expert, but I do think that Cliff would agree that view components can have lots of logic. A Mediator is just the way a view component has access to the system without actually knowing about the system.
I the case of loading a swf that most likely contain some visual presentation of data(?), I would usually use some container as a view component, and have that handle the loading and error handling. The mediator could pass data to this view component and that would know how to present that data.
(If the swf contains fonts I would normally load it from a proxy in a startup sequence)
Logged
puremvc
Global Moderator
Hero Member
Posts: 2871
Re: Page 'redirect' in Mediator or Command?
«
Reply #5 on:
January 01, 2010, 08:13:25 »
View components should encapsulate their own behaviors and this can cause them to be more complex than you might. Consider a map component might be created for resale or distribution. It might have quite a lot of logic in it that causes it to do awesome things with the map data you give it. In order for it to remain portable, it should encapsulate its behaviors, not have them controlled from code in the mediator. This will allow the component to be easily adapted to the PureMVC system or any other system. If you rely on the mediator to do the magic, then you tie the component to the PureMVC framework.
-=Cliff>
Logged
jlahr
Jr. Member
Posts: 19
Re: Page 'redirect' in Mediator or Command?
«
Reply #6 on:
January 04, 2010, 08:35:05 »
In this case, the View Component is solely responsible for loading SWFs according to user input and application state so it needs to listen to notifications coming from any number of cores. I figure it doesn't make sense to put notification handling in the View Component since that's what the mediator is good at. So I have a mediator that listens for any LOAD_X notifications and calls the the View Component's loadPage(X) method, which in turns loads a new SWF and a new core.
Even though my View Component relies too heavily on its mediator to tell it what to load, I feel like the component itself is a pretty reusable piece of code in that just loads whatever SWF the mediator passes it.
I'm still developing this so I can't say if it'll work or not. This is just my interpretation on how to implement a Shell core that will allow me to load SWFs on demand.
Logged
Pages: [
1
]
« previous
next »
Stack Overflow
GitHub
Linked In
Google Plus
Twitter
Powered by SMF 2.0.15
|
SMF © 2006-2007, Simple Machines LLC
|
Content © 2006-2018, Futurescale, Inc.
Loading...