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: Dynamic Mediators and Notifications  (Read 10444 times)
Dal
Jr. Member
**
Posts: 16


View Profile Email
« on: April 21, 2008, 03:18:01 »

Kia Ora,
Firstly I'd like to say well done to Keith its a nice scaleble framework.

This is my first attempt at MVC and Flash AS3 Framework, I am creating menu structures and stage layouts dynamically dependent on the page that is read in, all my Mediators and Components are created dynamically from recursive simple and macro commands.

What I am finding though is that because I am creating them all dynamically, when sending a notification to the menu for example I am having to have all my mediators receive the notification and react only if their mediator name is the same as that which is sent in the notification......

Although this works, the result is complicated code that is not very easy to follow, I also think that its a little too dependent on each other and not as loosely coupled as it could be - i'm sure if a came back in a month I'd have trouble following it!

Does anyone have an example where they have used dynamic mediators in a different way?????


Cheers
~D



Logged
Dal
Jr. Member
**
Posts: 16


View Profile Email
« Reply #1 on: April 21, 2008, 05:54:31 »

sorry clif not  keith I is tired
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #2 on: April 22, 2008, 08:59:52 »

You can use the type property as the discriminator, but you're still having to check it. You could create a one or more dynamic notification names that's the sender will use to target a specific receiver without knowing who it is. That would entail dynamically generating one or more strings in the array that the mediator returns when listNotificationInterests is called.

-=Cliff>


Logged
Dal
Jr. Member
**
Posts: 16


View Profile Email
« Reply #3 on: April 23, 2008, 02:55:24 »

Hi Cliff,
Thanks for the thats a ninja move - I know you are probable kept pretty busy.

My listNotificationsInterests is starting to get around 5 or 6 in the array - I know in your documentation you said if it gets over 3 or 4 then you should be looking at segregating them out, is it possible for one component to have multiple Mediators? Is that a wise move?

I would be pretty keen to get your input on the coding at specific points within this project if thats  alright??

Cheers
~D
Logged
Joel Hooks
Courseware Beta
Sr. Member
***
Posts: 146


baby steps

 - 46288188  - passport@provinsal.com  - joeltuff
View Profile WWW Email
« Reply #4 on: April 24, 2008, 10:20:58 »

A single component can have multiple mediators in the respect that a component is probably made up of sub-components. So say you have a LoginForm, you could technically mediate the submit/cancel buttons and each text input - not that you'd want to, but they are individual components and controls, so they can be mediated as necessary. This applies to your custom components and the sub-components/controls contained within.

It is also technically possible to mediate a component with two separate mediators, but I doubt that cliff would recommend this ambiguous practice.
Logged

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


View Profile Email
« Reply #5 on: April 24, 2008, 10:02:17 »

Hi Joel,
Chur for the reply, what would you recommend then?

I could easily have 10 - 20 functions in my notifcationsList - but it seems like alot and becomes a large switch case statement.....
How would I go about simplifying the coding and not creating a huge document for other users as well as my self??

Cheers
~D
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #6 on: April 25, 2008, 08:34:29 »

If you're at the point of having one mediator handling 20 or more events or notifications, then the view component it is mediating is probably too monolithic and should be broken into multiple components, each with its own mediator.

-=Cliff>
Logged
Dal
Jr. Member
**
Posts: 16


View Profile Email
« Reply #7 on: April 26, 2008, 07:33:58 »

chur Cliff
chur Joel

will break it down and go from there.


Cheers
~D
Logged
Pages: [1]
Print