I have read very carefully the prism MSDN documentation on "Communicating Between Loosely Coupled Components" but I want to be sure that I understood correctly when & how to use the event aggregator and the shared service.
I hope that you can help me checking my understanding. I am taking a simple example for that purpose:
I suppose that I want to develop an application that is able to load a list of records and expose several subsets (eventually overlapping) of the loaded data in various views (interacting differently with the user). Once the loading is done, if the user
select a record in a view, the other views are notified in order to react if they are also containing the record.
To my mind, it can be done with:
- a shared service which manage the data loding
- three GUI modules respecting the MVVM pattern
The shared service exposes an interface in the infrastructure library which defines an event
As it is a shared service, the view model class of the GUI modules can use dependency injection in order to access it ([ImportingConstructor]) and have the possibility to subscribe to this event. When they receive the event,
they can populate the associated models (ObservableCollection?) with a subset of the data (depending on some criterion).
Besides that, there is a class (defined in the Infrastructure library)
RecordSelected : CompositePresentationEvent<Record>. The three view module can have access to the shared service
EventAggregator through dependency injection and subscribe this event. They are also publishing it when there is a click on a record. In this case, the other modules receive it and can react accordingly by checking if they contain the record
I hope my example is clear enough so you can help me...
Does this structure seems ok to you? Can you provide me some corrections/advice if not?
Thanks a lot,