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: Mediators Send, Declare Interest In and Receive Notifications  (Read 6222 times)
Helmut Granda
Full Member
***
Posts: 47

Flash Developer.


View Profile WWW Email
« on: June 25, 2009, 02:08:21 »

From the documentation:

When they are registered with the View, Mediators are interrogated
as to their Notification interests by having their listNotifications
method called, and they must return an array of Notification names
they are interested in. 
 
Later, when a Notification by the same name is sent by any actor in
the system, interested Mediators will be notified by having their
handleNotification method called and being passed a reference to
the Notification.

Here is my question. I have views within my views like this:

top level view -
---mediator
-------low level view

now the "low level view" is instatiated by the mediator and it is basically a button. I am able to send a notification from the "low level view" that the mediator recognizes and is able to process correctly but I am 100% percent certain this is not the way to go. Having access to the facade from any place makes it easier to send notifications from any where but is that beneficial?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: June 25, 2009, 06:26:36 »

Don't send notifications from within your view components, it makes them less portable. The view component should not be aware of the PureMVC apparatus and should communicate with the system by exposing an API of events, methods and properties that the mediator can listen for, call and set respectively.

-=Cliff>
Logged
Helmut Granda
Full Member
***
Posts: 47

Flash Developer.


View Profile WWW Email
« Reply #2 on: June 26, 2009, 09:27:26 »

It does makes total sense and it is the core of this kind of development.

It is so tempting to do the wrong thing with so much power.
Logged
Pages: [1]
Print