Handling Events from General Management in MVC

In the application I'm working on, I applied the MVC pattern to use different views to display parts of the user interface. The general user interface has an input field in which the user can give commands or requests. The idea is that this input block generates several basic events, such as ValidEntry, InvalidEntry, and EmptyEntry. Each part of the controller must respond to these events. I do not want each controller to be subscribed to the ValidEntry event for a response, only the one that is active.

I could add an β€œif” to each event handler that checks if this.IsActive is true, and updates it on each view switcher. Or add different events for all different controllers. Any better ideas on this issue?

+3
source share
3 answers

Assuming that only one controller is active at once, how about having some kind of dispatcher manager class using the SetActiveController method. The manager will subscribe to user interface events and call the approproate method for the currently active controller.

+1
source

, "" , , , " " / , , , . / .

+1

, ValidEntry, , - "" , .

, , , , . :)

+1

All Articles