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

Show Posts

| * |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / Architecture / Best practice for mouseEvents in Mediator on: April 29, 2011, 04:29:33
Hi, I was wondering what is the preferred way of handling mouseEvents in regard to the independence of the view component and its mediator?

For instance, I have a button which I have to have a listener for in the mediator that tracks that it has been clicked and then sent to a command in the framework. So it would make sense that I add a listener for it from the mediator. But that same button has an effect on the view component itself at the same time (toggling visibility of other elements in the view component). So I came up with the following possibilities:

1) Add only the listener in the mediator, and handle the sendNotification and view component's elements through the shortcut viewComponent getter method

2) Have an independent mouseListener in the mediator that handles only what needs to be communicated with the rest of the framework AND have an independent listener in the view component to handle its own visual elements

3) Have only one mouseEvent listener in the view component, which then dispatches an event listener (a text string) up to the mediator once it is clicked.

1 offers less code, 2 seems to be more in line with my limited understanding of the appropriate roles of mediators, and 3 seems to just be an alternate version of 2. It seems somehow wasteful to have 2 mouseEvent listeners on the same object, however.

Any ideas as to what is the best practice?
Pages: [1]