Keeping views updated

Topics: CAB & Smart Client Software Factory
May 27, 2007 at 1:50 PM

What is the best way to keep my views(SmartParts) updated when changes accure in my data.
ControllerA ----------> ControllerB ------------> MyServiceAgent(Updated data)

My concern is how should i notify ControllerA that data is changed so the appropriate views
will update them selfs.
Should the ServiceAgent Raise the DataChanged Event?
Or ControllerB should do this?

When the views catch the DataChanged event should thay load the data from scretch or only update the newly added data, and if so should i wait for my service to finish the updating job and only then raise the desired event.

Thanks in advance Alex.

May 27, 2007 at 3:24 PM
There's two types of data changes to think about:

(a) User changes to data
(b) Service reload of data

I think you're talking about (b) so I'll answer that one.

When a service returns a new data object we have the class responsible for making the service call (in your case, it looks like ControllerB is doing that job) broadcast an EventBroker event that all interested view/presenters listen for. In many cases, we then use the EventArgs<T> to pass the data to the view/presenters so they can update themselves.

May 27, 2007 at 4:27 PM
Thanks for your help Chris

Your suggestion is already implemented in my application\
can you please elaborate more about User changes to data.

Thanks for your help