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: Multiple delegate service parameters in different views  (Read 11130 times)
Roustalski
Jr. Member
**
Posts: 13


View Profile Email
« on: January 23, 2009, 03:21:21 »

Lets say that view comp 1 with mediator 1 has a text field for searching.

View component 2 with mediator 2 has two date fields for start and end times for the search.

Lets also say that view component one dispatches an event to initiate the search, the mediator translates that to a notification/command pair. The command then retrieves a proxy and invokes a method that requires all 3 parameters.

How would you handle this?

The options as I see it:

1. View Comp 1 grabs the time params from View 2 and exposes the API to the mediator.
2. View Comp 1 Mediator 1 grabs the time params from View 2 Mediator 2, and then sends the notification with all 3 parameters
3.View Comp 2, when initialized and interaction with the time controls occur, sends a notification that maps to a command that sets the time parameters on the proxy. View Comp 1 then sends it's normal notification with its parameter, the command invokes the search method on the proxy with the search text, and uses the already stored time values from the other notification.
4. Some sort of AsyncCommand magic, where each mediator is polled (via notification I presume) for it's parameters and then launches the search command.
5. Other?

Thanks.
Logged
Joel Hooks
Courseware Beta
Sr. Member
***
Posts: 146


baby steps

 - 46288188  - passport@provinsal.com  - joeltuff
View Profile WWW Email
« Reply #1 on: January 24, 2009, 08:40:23 »

When the search parameters are changed they are stored to a SearchParamsProxy (with perhaps SearchParamsVO as the data) whish is then referenced for the actual search.
Logged

http://joelhooks.com - my ramblings about developing with actionscript and python using pureMVC and django respectively.
Roustalski
Jr. Member
**
Posts: 13


View Profile Email
« Reply #2 on: January 25, 2009, 05:02:08 »

What reasoning do you use for keeping the parameters in a different proxy as opposed to the one who will actually use it?

In this simple scenario at least...
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: January 27, 2009, 06:38:16 »

Because it is data collected from several places in the app which another actor will use to perform a search. This keeps the searching actor from being coupled to the varied sources of the search parameters, which could concievably change.

Its sort of like all the employees (mediators) taking their time cards to the punch clock (SearchParamsProxy) where they're collected later and entered into the accounting system (search happens). No need to go collect them from each employee.

-=Cliff>
Logged
JJfutbol
Sr. Member
****
Posts: 53


View Profile WWW Email
« Reply #4 on: January 29, 2009, 11:32:32 »

Agreed with Joel and Cliff. I actually use the same approach for filtering/sorting. I'll have say a TaskProxy where I maintain a collection of tasks, allow creating, updating, etc. My service interactions are maintained there. But the way I filter the data is very unique and doesn't necessarily match or behave with explicit fields. I like having this in its own proxy, TaskFilterProxy in this case, since it can change (new filters, changing others) and its important enough to have on its own.

Also I would store the current filter/sort selections in the TaskFilterProxy much like how you would store the search params in a SearchParamProxy. So I would have selectedFilter and selectedSort properties (thanks to Cliff for this tip from meeting you at MAX)! At the end of the day someone needs to be responsible for globally maintaining a selection so in my case the best choice was the proxy (or at least it made most sense there). This proved incredibly helpful since I have a single command FilterTasksCommand encapsulate the necessary logic (command doesn't receive any body, then it assumes current selection for filtering, critical if your app does refreshing behind the scenes!).
Logged
Ilan Avigdor
Courseware Beta
Newbie
***
Posts: 5


View Profile WWW Email
« Reply #5 on: March 14, 2009, 09:05:55 »

We are in the design phase of a PureMVC based system with similar requirements, and this thread is an important take on this issue. Thanks!

Our system, however, like many others, requires that the search/refresh should be initiated when changing any one of the filtering views (i.e. view component 2, which holds the start/end times).

In addition, the same filter change can require refreshing different types of data/proxies for different data representation views (i.e. changing the end date should refresh both tasks and appointments lists).

The options we see are:
1. The filter proxy (i.e. TaskFilterProxy) sends a FilterUpdated notification, handled by a command that is responsible for calling the relevant proxies to refresh.

This approach leaves the data views "clean", showing interest only in changes to the data they represent, regardless of the reason it was changed. However, the command handling the filter updated notification becomes somewhat of a maintenance bottleneck.

2. The mediators which should refresh as a result of a filter change handle the filter updated notification by sending some kind of a "need to refresh" notification, which causes the relevant proxy to refresh.

This approach encapsulates the need for a refresh in the data representation mediators, but makes them less reusable (for apps which doesn't use the same filters).

Any insights/additional options are most welcome.

Thanks,

-Ilan
Logged
Pages: [1]
Print