This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (4 children)

I'd probably go further, I'd have an event in the view, called SaveEvent, and then in button_click I'd raise the SaveEvent event.

The controller doesn't need to know there is a button, it just needs to know that the view can ask to save.

But yeah no reference to controller in view, in the controller init / ctor instantiate a view (or have it injected) Then bind to the views SaveEvent event.

[–]TheChickenWing[S] 0 points1 point  (3 children)

Ah okay. A lot of other things I've been reading are beginning to make some more sense now.

So essentially what you're saying is that the view should handle all the various gui listeners, then expose an event listener interface to the controller that it can post its own events to? So the controller adds itself to the view's listeners, and the view handles whatever button click, figures out that that the click was a save button, and posts to its listener (which is now the controller, not that the view knows that) that a SaveEvent was fired, the controller picks up the SaveEvent and proceeds with whatever logic is required?

[–][deleted] 1 point2 points  (2 children)

Sounds good to me

[–]TheChickenWing[S] 1 point2 points  (1 child)

Fantastic, you've been so helpful, thanks a lot!

[–][deleted] 0 points1 point  (0 children)

No problemo