PureMVC Architects Lounge

Announcements and General Discussion => Getting Started => Topic started by: landed on May 01, 2009, 10:05:09



Title: Anatomy of a chain of events
Post by: landed on May 01, 2009, 10:05:09
Just want to see if I have this right from what I can tell.

Objective : have a UI element send data to the model process that data and display a result in the same (or not) UI. Must keep encapsulation.

UIView > dispatchEvent to its Mediator
UIViewMediator > sendNotification(include value object or other data) to a controller (which controller)
UIViewController > sendNotification(include value object or other data) to ModelProxy
ModelProxy > sendNotification(include value object or other data) toModel - do thing and then go all the way back.

I have left out the facade here on purpose as I would like to see how it could be done using that. I think how I have it here is more traditional MVC, with pure I seem to be seeing that I can go straight to the Model with facade ?

thanks for developing this thread...


Title: Re: Anatomy of a chain of events
Post by: puremvc on May 02, 2009, 06:10:48
Three things that are wrong:

1) Command not Controller. Their is just one Controller and it executes Commands mapped to Notifications.

2) The Command retrieves the Proxy and gives it the data. The Proxy 'has no ears'; it cannot receive Notifications. If it could, it would be too tempting to have it listen for notes defined elsewhere in the app, making it less reusable. (Always assume you'll reuse your model tier classes in another app).

3) By using sendNotification, you've already used the Facade. sendNotification is a convenience method that uses the local reference to the Facade that every Command, Mediator or Proxy already has.

-=Cliff>