PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: Helmut Granda on June 25, 2009, 02:08:21



Title: Mediators Send, Declare Interest In and Receive Notifications
Post by: Helmut Granda 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?


Title: Re: Mediators Send, Declare Interest In and Receive Notifications
Post by: puremvc 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>


Title: Re: Mediators Send, Declare Interest In and Receive Notifications
Post by: Helmut Granda 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.