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

Show Posts

* | |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / Getting Started / Asynchronous proxy with multiple clients on: November 20, 2009, 12:46:51
I have an asynchronous proxy (P1) which uses a remote object to retrieve data from php services (using amfphp).
When my mediator (M1) wants to get data for its view, it calls a function (f1) of P1.
This function calls the php service. Response of php service is caught by another function (f2) of P1.
This function puts the result in a public var of the proxy and sends a notification telling that data has been received.
M1 is an observer of this notification and updates data of its view using P1 public var.

I have a new mediator M2 who needs to use the same service with different parameters.
If I use the same mechanism, P1 will send the notification telling that data has been successfully retrieve and both M1 and M2 will update their data.
I don't want M1 to update its view when M2 uses the service and vice versa.

I have thought of two ways to have the behaviour I expect.

First solution.

When M1 calls f1 function, P1 uses a private var used to store the 'id' of the requester (M1) of the service.
When f2 receives data, it sends a notification depending on the requester (DATA_FOR_M1_RECEIVED, DATA_FOR_M2_RECEIVED).

Second solution.

f1 defines the function listening to the response of the php service depending on the requestor.

I don't like those solutions :(
It would be much better to define function managing response as parameter of the function calling the service.

I'm looking for good ideas ;)

I'm convinced that experienced users of flex have already found elegant solutions for this problem.
2  Announcements and General Discussion / Getting Started / Re: Application Mediator for tabNavigator on: November 18, 2009, 10:20:36
Thanks. I will only create and register mediators when needed if they are not yet registered.

I have created the following method in my ApplicationMediator.

:
private function checkForMediator(mediator:Class, view:Object):void
{
if (!facade.hasMediator(mediator.NAME))
{
facade.registerMediator(new mediator(view));
}
}
3  Announcements and General Discussion / Getting Started / Re: Application Mediator for tabNavigator on: November 17, 2009, 11:24:31
SHOW_TAB1, SHOW_TAB2, etc (SHOW_TABx) are names of events fired by the application.

I have read once again Slaker demo comments http://puremvc.org/content/view/92/1/.

I understood that tabNavigator has a default creation policy set to auto to improve application startup speed.

I said that my ApplicationMediator adds and removes mediators linked to tabs depending on selected tab.

Is it usefull to remove mediators ?
Does tabNavigator remove view components when they are not needed for a long time ?

If removing is useless, I just have to create and register needed mediators the first time user selects a tab.
4  Announcements and General Discussion / Getting Started / Re: Application Mediator for tabNavigator on: November 17, 2009, 03:18:25
There's no notifications in my management of tabNavigator ;)
The application catches tab changes and fires events using dispatchEvent.

ApplicationMediator adds event listeners, listening to those events in its onRegister method.

Each method called by on of those listeners, registers mediators and removes others.
5  Announcements and General Discussion / Getting Started / Application Mediator for tabNavigator on: November 17, 2009, 02:10:37
I have seen this post http://forums.puremvc.org/index.php?topic=842.0
and this demo http://puremvc.org/pages/demos/AS3/Demo_AS3_Flex_Slacker/srcview/

I have created an ApplicationMediator listening to my application which has a tabNavigator.

My main application fires and event each time selected tab changes (I use change event of the tabNavigator). Events are SHOW_TAB1, SHOW_TAB2, etc. ApplicationMediator listens to those events.
When SHOW_TABx is fired, ApplicationMediator removes mediators linked to over tabs and registers mediators linked to the one selected.

onRemove method of all my mediators removes listeners linked to the mediator removed.

Is it a good way to manage registration of mediators linked to tabs of a tabNavigator ?
6  Announcements and General Discussion / Architecture / Re: Mediators organization on: November 15, 2009, 12:25:41
Thanks for all your replies :)
7  Announcements and General Discussion / Architecture / Re: Mediators organization on: November 14, 2009, 10:06:33
Thank you for your answer.

I have a mediator which manages the currentState of its view. I'm going to change that and make the view manage its view states :)

My main question still remains ;).

Imagine my main application mxml file (main.mxml) having two view components panel P1 and panel P2.
Each panel has its own mxml file (in the view/components directory).
P1 has a mediator M1 and P2 has a mediator M2 (each mediator has its own source file in view directory).
I define states and transitions of my application in the main.mxml file.
Suppose, base view state has both panels and another view state S1 has only panel P1.

Changing from base state to S1 will remove child P2.
Do I have to remove M2 before this states transition ?
Do I have to create once again M2 after a transition from S1 to base state ?
8  Announcements and General Discussion / Architecture / Re: Mediators organization on: November 14, 2009, 03:42:07
Thanks for the code example.

I don't really want to manage states of my application with FSM now (maybe later). It has not lot of states.

My problem is to manage view transitions of the application.

If I define states and transitions in my main mxml file, who will manage those view states ? A mediator ?
Those transitions will remove and add panels already managed by their own mediators.
Will I have to remove a mediator if the transition removes its panel ? And create it again when another transition creates the panel ?
9  Announcements and General Discussion / Architecture / Re: Mediators organization on: November 13, 2009, 02:48:35
Thanks for your reply.

This StateMachine looks powerfull to manage states of an application. I'm going to try to use it.
Is there any code examples ?
I hope I will be able to manage view states transitions too.
10  Announcements and General Discussion / Architecture / Mediators organization on: November 13, 2009, 10:09:32
Hello, it's my first message here :)

I use PureMVC for my Flex application.
The main mxml application file has three panels in.
Each panel is linked to its mediator.
I already manage states in each panel using their mediators.
I wan't to manage states of my application to remove or add those panels.

To be able to do that, I want to add a container (panel for example) at the top level of my application (containing the three panels) with its own mediator.
This mediator will observe notifications to change the state of the application. I think I will have to manage registration of mediators linked to panels added or removed.

Do you think it's a good idea ?
Pages: [1]