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: First PureMVC Project  (Read 10727 times)
BruceAlmighty
Newbie
*
Posts: 3


View Profile Email
« on: July 27, 2010, 10:17:18 »

Hi

So I've been reading through several tutorials and gone through some demos over the last couple months, trying to understand PureMVC and MVC as whole.

I decide to do the new project I've been assigned to at work in Pure MVC, I figured it will be the best way to learn it, by getting straight into it.

Simple over view of what I need to achieve....

1.) A simple form button, with a popup for the user name (with some validations), after which the user can be added to the game.

2.) A dummy chat system, in which the same user can click the chat button and it shows up during the game.


I have made ways on this, but I am not sure if I am going about it the right way.. just want to get a quick heads from the guys in the know on the best approach to this type of system.

Thanks
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: July 28, 2010, 01:28:12 »

I'd recommend reading Simon Bailey's posts about handling popups. http://www.newtriks.com/?p=329

And have a look at the Employee Admin demo which shows a bit about shuttling data around inside the app.

Also, possibly look at the Slacker demo if you run into some deferred instantiation issues (i.e. chat window appears after all the mediators have been added and the user logs in, so how get a mediator around it).

As far as chat goes, you'll have a ChatChannelProxy or some such which subscribes to the RTMP channel and is used to send and receive messages. It'll throw incoming messages at the view by notification where a ChatWindowMediator or suchlike will grab it and poke it into the chat window. That same mediator will listen to events on the chat window and send off a notification with the message and username in the window. Chat's pretty easy.

-=Cliff>
Logged
BruceAlmighty
Newbie
*
Posts: 3


View Profile Email
« Reply #2 on: July 29, 2010, 02:23:43 »

Thank you for the response I will have a read through the links....

Since the last post I manage to get the popup going, but I am not sure if it's the conventional way... the way I've done it for now is:

GameMediator listens to popup request, then it calls UIGame to show popup, UIGame then calls the UIPopUp.

Ideally though I would prefer for GameMediator to call UIPopUp directly, rather than going through UIGame, if that makes any sense. Also in a scenario where user clicks a login button, with a popup box with "username" input field, would I need to send the user input data to the Proxy first?.

I have other questions as this is quite a complicated project..

Thanks
Logged
jpwrunyan
Sr. Member
****
Posts: 84


View Profile WWW Email
« Reply #3 on: July 29, 2010, 10:47:26 »

For Alerts, I do it basically the way you describe. 

The Alert.show() logic might be inside my actual mainViewComponent and then if some other logic wants an Alert to be shown, it dispatches the notification, the MainViewMediator picks it up, and then tells the mainViewComponent to show an alert.  This allows the actual alert implementation to be independent from everything else.  If I decide to stop using Alert.show() and instead use PopUpManager, the logic is contained in the mainViewComponent--anyone can mess with it and not break the overall framework (or even know anything about it).  Convenient for handling little changes like styles or other Flex-dependent aspects of popups.

Maybe a distinction between advanced popup components and simple alerts in your application will make the right course of action clearer?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #4 on: July 31, 2010, 06:41:12 »

What you are doing is fine if you're just wanting to show an alert with no feedback from the user.

An advanced usage of popups that would push you toward mediating the popup itself would be when the popup needs collect information from the user. Say you're popping up a login box that asks for username, password, remember me, signup mode with password confirmation, and forgot password. That's a full-on component worthy of independent mediation.

-=Cliff>
Logged
BruceAlmighty
Newbie
*
Posts: 3


View Profile Email
« Reply #5 on: August 05, 2010, 05:17:02 »

Thanks Cliff

I have manage to get over the pop up hurdle...

What I am not having problem with is the passing and exchanging of information to and from the proxy and how that will link to the VO, techinally I understand what I need to do, I can't seem to find a good example/demo of this.

Something along the line of the questions asked here

http://puremvc.org/content/view/84/188/

In a nutshell... after the user puts their name in the popup textbox and close... how do I send the data that have inputed to the proxy, once the proxy recevies this data (I'd imagine it will store it, but where?)...

Once the proxy has received and stored the image, how would the mediator get the those value from the proxy and update the view components.


thanks
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #6 on: August 06, 2010, 07:29:37 »

We do need a popup-focused demo.

Most view components are already created by the time the PureMVC apparatus is made aware of the view hierarchy, and usually they hang around for the life of the program. That means at startup we can mediate them and never worry about removing the mediators.

Popups and components subject to deferred instantiation are the exceptions to the rule and require special handling in order to mediate them at runtime after startup. Popups differ from deferred instantiation in that not only may they be added to the view hierarchy late, but they will be removed at some point and so their mediators will also need to be removed.


But remember: once mediated, a popup is just like any other component; the only difference is its life cycle.

So for getting data into it, have the mediator listen for notifications or retrieve data from proxies (or both), and set that data on the popup.

For getting data out of it and back to a proxy, listen for events on the view component, and handle them by either setting the data on proxies directly, or sending it off in a notification to a command which sets the data on the proxy (and possibly does some business rule validation and/or coordinates updates of multiple proxies).

Have a look at the Employee Admin demo for Flex. It has nothing to do with Popups (which you've managed to mediate now like any other view component), but it does show custom components having data passed to them, allowing the user to modify, create or select data, and passing that data back to the Proxies.

-=Cliff>
Logged
Pages: [1]
Print