Flex - Design - Mediators Coupled To Proxies In Flex PureMVC?

Aug 14, 2009

I've just recently learned the PureMVC framework, and am a little confused as to the coupling between Proxy and Mediator objects. The links on this page connect to some documents describing the framework. (Please note, the links on the aforementioned page open PDFs.)

The diagrams and examples of PureMVC I've examined often show a direct coupling between a Mediator and Proxy. When the proxy's state is updated, rather than sending a new Notification, the Mediator (which retrieves a reference to the Proxy from the Facade) has its state updated.

This certainly seems to simplify the logic of the code, but it also directly couples two seemingly disparate components together. To my understanding, a Mediator's purpose is to translate Events from a view into PureMVC Notifications. Proxies are meant to perform some function to gather data and relay it back to the view. These two components seem to exist in different layers of the application, and perhaps shouldn't necessarily be coupled together.

Wouldn't it make more sense to have the Proxy objects send their own Notifications when their state updates, which are forwarded to the interested Mediator by the Facade?

View 2 Replies


Similar Posts:


ActionScript 3.0 :: PureMVC Dilemmas - Getting References To Proxies/mediators By Global String?

Jan 26, 2009

As part of the learning PureMVC I've created this example (sources). And I must say that I'm quite disappointment about PureMVC.Here's things that I don't like:

1. Getting references to proxies/mediators by global string.

Code:

var model:SomeProxy=facade.retrieveProxy(SomeProxy.NAME) as SomeProxy;

What's the point in this? In that case why just don't create bunch of references in static public variables in some main class (ApplicationFacade.someProxy)? And after all, what if I want to have dynamic number of proxy/mediator class instances? Ones removed, another ones is created in running time.

2. "The events (notifications) from nowhere, handled by anyone" Let's say I have at my app five models of clocks. And I have also five corresponding views of clocks. With every thick of every clock model, one of clocks views should be updated.In normal approach there's just created control class which create view and model instances, and make decisions if there's any events from them.In PureMVC looks like there's only "global events" - ApplicationFacade.SOME_EVENT so if I want to do my 5 clocks I will have to:

- create notfication id: ApplicationFacade.CLOCK_TICK

- broadcast about it. But I will have to also pass the reference from what clock model it's:

Code:
sendNotification(ApplicationFacade.CLOCK_TICK, this);Now, from some command class that handle that event, should be made decision about updating certain clock view. The question is - from where that command class will know *which* clock view it is? And why this must be so complicated? Updating all clocks with every tick event is not the answer.

BTW: comments from INotification.sendNotification

Code:
@param notificationName the name of the notification to send
@param body the body of the notification (optional)
@param type the type of the notification (optional)
"name" is name, "body" is body, "type" is type - o rly?

3. Only "one level" model allowed?

I don't know how to say this clear so maybe images will be better

In PureMVC conceptual diagram things looks like this: But in real world things looks more like this: Our SubSubModel should have some kind of proxy? Or only "first level" models "deserve" for proxy?What if SubSubModel visual representation is so complicated that it should have dedicated view. How that view will get reference to that "deep-level" model? How they communicate?

View 1 Replies

Flash :: PureMVC Mediators And Views - Creation And Control?

Aug 16, 2011

I'm making an app with flash AS3 and puremvc, the way to correctly handle view mediators is sort of throwing me a little...I have 3 or 4 distinct views, each governed by it's own mediator.Each view is only displayed on its own - ie. when 1 is visible/on stage - the others are invisible/removed from stage (over simplified, but I guess could be thought of as seperate pages, viewed one at a time, a nav bar allows a user to change views when they like)

At first each view mediator I had creating and added to stage it's own view component, and as such, when it was 'turn' to show or hide that view, it was simple - addChild and removeChild for it's view component.However, I read over at puremvc.org that it's not good practice to

a. pass round the stage (which was the viewComponent for each mediator in my case - where each view was added to - eg. viewComponent.addChild(foo)

b. create its own view - which allowed me to add and remove it in the first place.

So I changed to the recommended way - when I create each mediator, what I pass in is the view component it governs (rather than the stage/main doc class eg.

var view:MyView = new MyView();
facade.registerMediator( new MyViewMediator( view ) );
viewComponent.addChild(view);

with that the case - I have no idea how I would go about removing/adding each view when needed.I could easily enough set the visibility from within each mediator, but I sort of wanted to avoid doing that - prefer removing when not in use for resource management...how I am 'meant' to go about this (as in, when a view is no longer needed on stage, remove it - temporarily, and add it later on when it is needed?)

View 3 Replies

Actionscript :: PureMVC Proxies Send Notifications Themselves ApplicationFacade?

Aug 24, 2009

In the PureMVC framework, Proxies communicate with the ApplicationFacade (and thus any interested components) via a Notification. Should this Notification be sent via their own instance, or the Singleton instance of the ApplicationFacade? Frankly, does it matter?

[Code]...

The second method looks more verbose and less intuitive to me. Moreover, the Proxy has the ability to send Notifications, which, in my mind, means it probably should. Are there instances where the Proxy should only send a Notification via the ApplicationFacade instance?

View 1 Replies

Flex :: BlazeDS/PureMVC And Shared Vos?

Apr 21, 2010

I'm building modular application with 2 modules which share common vo: ShopRegionVO

This vo is also a BlazeDS entity and is mapped to a remote java object. When shell loads first module everything is ok. The second module is a list of ShopRegionVOs and item change is handled with the following code:

sendNotification(CoverageConstants.SET_SELECTED_REGION_COMMAND, ShopRegionVO(List(e.target).selectedItem));

The exception is thrown right here:

Main Thread (Suspended: Error #1034: Type Coercion failed: cannot convert model.vo::ShopRegionVO@14961809 to model.vo.ShopRegionVO.)
view.list::RegionListMediator/onChange
flash.events::EventDispatcher/dispatchEventFunction [no source][code].....

View 1 Replies

Flex :: PureMVC: Unique Mediator For Each Tab In An Interface?

Oct 12, 2009

I am building a tabbed interface for switching between various similar layers. Each layer will have a number of graphs. By dragging with the mouse the graphs can be rearranged or even moved between layers. My question is, is it best practice to register a unique mediator for each layer that keeps track of the layers content / organization, or should i keep track of it all with one central mediator.some considerations:

the layer contents and organization will be saved(in a db) so that it can be restored when a user comes back to the app.the layers themselves are functionally identical.the user can add and remove layers at will.

View 1 Replies

Flex :: Mediator Must Hold View In PureMVC?

Dec 28, 2009

I have one question about pureMvc. I use pureMvc to build an engine, in the engine init part i have an requirement

1) moduleA must init firt
2) moduleB , moduleC need init after moduleA init complate.
3) moduleD need init after moduleB & moduleC init complate.
4) moduleA , moduleB , moduleC , moduleD all extends Proxy beacuse the four system all need to send notifiation ,but no need to listen it.

But to fit for the requirement I can't use command to do it, because they have ini order and also they need to remember current state(ex: moudelB is init Complate but moudleC is not init complete then can't init moudleD) but command is stateless. The best way I think is use one Mediator to do it, beacuse it can both listen and send notification. My question is :

1) Is this a good way to use one Mediator to do it?
2) If use Mediator is good way, then when it hear first moduleA is init complate
registerCommand(FIRST_MODULE_INIT_COMPLATE , initStepTwoCommand);
sendNotification(FIRST_MODULE_INIT_COMPLATE);
removeCommand(FIRST_MODULE_INIT_COMPLATE);
Need to do things like that way or just do the inti logic in the Mediator?

View 1 Replies

Flex :: Multiple Instances Of Views In PureMVC

Sep 15, 2010

Often multiple instances of the view component would be used in multiple places in an application. Each time I do this, I register the same mediator with a different name. When a notification is dispatched, I attach the name of the mediator to the body of the notification, like so:

[Code]...

View 1 Replies

Flex :: Implementing Process Workflow In PureMVC

Oct 11, 2011

I'm looking for suggestions regarding implementing process flow / work flow management in a PureMVC based application. Our Flex application includes a number of processes such as account creation, payment processing, etc. Within our team, there is some discussion of how rigidly we should adhere to the PureMVC model. Within the PureMVC model, it seems reasonable that the current state in the process could be managed in a Proxy. Commands are clearly responsible for processing the actions required of each node and for node transitions. Mediators for managing the UI.

However, I think that there is an important bit still missing here: a ProcessController. The approaches we've reviewed all seem to either violate the PureMVC model (even just slightly) or make unreadable code. A proxy would maintain the state of the process. As such, it seems to be an appropriate way to implement the controller. However, this is putting a lot of business logic into the proxy.

[Code]...

View 3 Replies

AS3 :: Flex - Inherited Classes And Dynamic Views In PureMVC

Jul 14, 2009

I was wondering best practices for views of inherited classes in PureMVC in this situation: Multiple classes inherit a BaseClass (lets say InheritedClass1 and InheritedClass2) Each InheritedClass has a respective view (derived from a base view class, but each unique) With a given dataset (lets say ArrayCollection of InheritedClass1/2 Objects), the respective views need to be dynamically loaded. The dataset is relatively large, so a TileList would be nice (since it only instantiates objects which are currently displayed) I can think of a couple solutions, but I find them to be too "hackish" to be the best solution:

In View: Repeater over a BaseClassView which attributes a view to a State (set to the "InheritedClass1" state to add a InheritedClass1 object) Pros: No unneeded memory increase (States' objects are instantiated when needed) Cons: View is dependent on the data types, so adds coupling In Mediator: Loop over the ArrayCollection and addChild() the views based on data type Pros: Works. Cons: Mediator is adding things to the View, which defeats the point of the separation of Mediator and View. Slower than a Repeater.

View 4 Replies

Flex :: Unit Testing Puremvc Based Application?

Jul 10, 2010

I have a flex application written using PureMVC framework.Now,I want to write tests.We are using FlashBuilder 4.Is FlexUnit sufficient for testing? Are there any issues you have faced while writing tests?

View 1 Replies

Flex - Design Patterns For Adobe Air/Flex Applications?

Jun 2, 2010

I'm going to write an application with the Air/Flex-Framework. I'm looking for Best Practise and general Design Patterns for designing software especially in Air/Flex. I have experience with this framework but never had the pleasure to write a piece of software from scratch.

For instance: I stumbled across lots of software written in Air/Flex with nearly infinity global vars Most of the software I saw was not object-oriented How can I pack the asynchronous method calls nicely?

I'm familiar with general design patterns by gamma. I'm looking more for advise in designing good quality software with Adobe Air/Flex.

View 4 Replies

Flex :: Architecture - Application Framework - PureMVC Portability Vs Swiz?

Dec 9, 2009

My company is building a Flex application that we may need to port to other platforms:

[Code]...

Currently, I'm looking into application frameworks to build upon and I'm torn between pureMVC and Swiz. I LOVE swiz for its simplicity and how it just gives you a way to hook things up and then apply your own patterns. From a flex-only perspective, this is my 1st choice. But, PureMVC is platform-independent and has already been ported over to most of the platforms that are mentioned above. How valuable is this portability? Will it really make our lives significantly easier when it comes to porting and developing/maintaining multiple applications? If so, then it seems like PureMVC is the way to go.

Alternatively, since Silverlight has the most definite business case for porting of our application, maybe we could port Swiz to Silverlight? I'm not too familiar with which AS3 language and Flex framework features Swiz depends on and whether they are available in C#/Silvelright.

View 2 Replies

Flex :: Creating RobotLegs Module Within A PureMVC Shell Application

Oct 19, 2010

I'm working on an existing modular project that was built in PureMVC. Instead of converting everything over to RobotLegs, I want to create a new module using RobotLegs and plug it into the pureMVC shell. Currently, when the module loads, I get the following flash error: ReferenceError: Error #1065: Variable IMediatorMap is not defined.

Inititally, I thought it was because my module needed a pureMVC Mediator to call the pureMVC StartupCommand to get things "hooked up" and THEN create the RobotLegs' Context. However, that didn't work and I'm still getting the error.

View 2 Replies

Actionscript :: Flex MultiCore PureMVC Notifier Initialization Error

May 27, 2011

I am trying to write a simple multicore PureMVC helloword. I am getting Error: multitonKey for this Notifier not yet initialized!

[Code]....

View 1 Replies

Flex :: Design Desktop App (from Web App Dev)?

May 16, 2010

I have only worked on web apps for my whole career.I'm starting a new desktop (Adobe AIR) app project but I found myself having difficulties with:

stuck with thinking about overall UI design in the traditional page model

not sure how to handle the navigation part in the UI

not taking advantage of states

deciding what should be implemented on client vs server side, (or on both?).

View 3 Replies

Flex :: What Was Design Decision Behind ItemPendingError

Jul 29, 2009

Flex has the notion of lazily loading data. It has a class named ItemPendingError which allows developers to handle it when an attempt is made to access data that is not yet available aka "pending".However, looking at the documentation it's clear you have to add try/catch blocks around your code wherever you have code that might cause an IPE (ItemPendingError) to occur.I'm curious if anyone knows why it works this way. I'm not sure what the best solution might be, but having to willy-nilly add in try/catch blocks to catch the error and then register a Responder with it feels bad and not very clean. And the fact that you sort of have to exercise your application to make sure you've caught all the possible places where the error might occur is also lame.Is there some other way or better approach that I haven't seen/heard of?

View 3 Replies

Periodic Table Design In Flex

Aug 27, 2010

I now need to design a chemistry periodic table. I will have a set of few elements that have been chosen by the user,and that should be reflected on the periodic table by making these few elements clickable.So when the user clicks on these few elements,corresponding explanation text will pop up on the text area outside the periodic table.Making all the elements of the periodic table buttons,so only the buttons that are within the set are enabled(clickable),while others are disabled.Embedding a static periodic table picture,and do things there(don't know exactly how yet).

View 1 Replies

Actionscript 3 :: Design Usa Interactive Map In Flex?

Jun 11, 2009

i need of simple UsA map in flex ,all Area need to be click able as button Is there any tool available for designing buttons in various shape in flex or any build in free map is available in flex. As vector format so that zoom in will not affect the quality.[URL]..

View 3 Replies

Flex :: Design - Gradient Fill Of Chart

Oct 17, 2009

I'm struggling to reproduce the gradient fill of this chart. Is there tools that help testing GradientEntry properties on fills?

View 1 Replies

Flex :: Design A Dynamically Changing Table In It?

Aug 30, 2010

I'm new to Flex 4 and have been doing the Flex in a Week crash course online.

build a dynamically growing or shrinking table with columns and rows. The cell backgrounds of the table will change color depending on an XML file.[url]...

View 1 Replies

Flex :: Design - Static Functions Or Events?

Feb 1, 2011

I'm working with an application which was originally designed to make heavy use of static-variables and functions to impose singleton-style access to objects. I've been utilizing Parsley to break apart some of the coupling in this project, and I'd like to start chiseling away at the use of static functions. I will explain the basic architecture first, and then I'll ask my questions. Within this application exists a static utility which sends/receives HTTP requests. When a component wishes to request data via HTTP, it invokes a static function in this class: Utility.fetchUrl(url, parameters, successHandler, errorHandler); This function calls another static function in a tracking component which monitors how long requests take, how many are sent, etc. The invocation looks very similar in the utility class:

[Code]...

View 1 Replies

Flex :: Implementation Of Value Object Design Pattern?

Jun 20, 2011

I am just looking design patterns used in Flex. Any value object design pattern and how is it implemented in Flex.

View 3 Replies

Flex :: Design Mode Not Working In Builder 3?

Feb 9, 2012

When i try to open my mxml script in design mode i'm always getting following message "This Component is base on VBox, which is not a visual component. Switch to source mode to edit it"

View 1 Replies

Flex :: Papervision3d - Design A Sphere With 8 Holes Around One Of Its Diameters?

Jun 22, 2009

I am a newbie to Papervision. I want to design a sphere with 8 holes around one of its diameters. How do I do it? How do I draw anything on a sphere in Papervision?

View 1 Replies

Flex :: Image Shows Up In Design Preview But Not Application

Jun 23, 2009

My embedded images show up in the Flex Builder Design Preview, but are not displayed when the application is run. The images have relative paths (/assets/images/...), and the application is run on the server (wamp). I've appended the path to the compiled location [URL] and tried to display a image in the browser, and the image exists, too. I've compiled it via FlashDevelop, Flex Builder, and Ant. I've deleted and remade the bin/bin-debug/release/bin-release files to no avail.

View 1 Replies

Flex :: Design - Changing DataGrid Highlight Color

Dec 29, 2009

How can i change the color, when the user mouse over an item on datagrid or tilelist. Basically once the user mouse overs and once the user selects a file. How to change the default color to something else. The default is blue and i dont like it :)

View 3 Replies

Use Flex's Coding Ability With Flash's Design Interface?

Dec 22, 2010

I am looking for some decent tutorial that will explain the correlation between flash and flex (how can I use flex's coding ability with flash's design interface).

View 3 Replies

Flash :: Design Tools For Creating Skins For Flex 4 Components

May 11, 2010

I'm looking for a tool to create just the skins for different kinds of Flex 4 components.I'd like to be able to create the components myself and have the designer/artist do the skin, but I don't think they'd like the idea of doing them by writing MXML files.

View 2 Replies

Flex :: Auto-mation - Design A Fully Functionnal Automated App?

Jun 25, 2010

We are currently thinking on getting our apps automaticaly built and tested through a CI server.My major concern is regarding UI tests.. I've been playing with FlexMonkium/Selenium IDE in Firefox but it doesn't really play nice with my app. I'm also testing RIATest 3 but I would have liked the Firefox approach better because it's easy to use for non technical users..A bigger concern is that my app is really complex, using custom events, custom components, ExternalInterface calls.. in order to make it all work smoothly, should I give an automationName to every single component ? How can I handle custom events ? RPC responses time

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved