Are both the EventAggregator used by ViewModel and Domain Event used by Model the same thing?
Posted on 2013-01-05
My initial doubt was should the Model classes in an MVVM use the EventAggregator or the traditional delegates in C# for events. I searched around and read about the Domain Events. It seems to me that for the Model classes, they should use the Domain Events instead of the EventAggregator, which is for the UI.
So, it would work out as something like: The ViewModels would use the EventAggregator to dispatch events between the other ViewModels. The Model classes would dispatch events on the Domain Event aggregator. The ViewModels, which knows about its own specific Model, will listen to the Model's Domain Events. The Models would communicate with the other Models through the Domain Events, decoupling among themselves. This would entirely eradicate the use of the traditional C# events.
Up till this point, I hope I'm understanding all that I've read correctly.
Now, here's what I don't understand. Both the Domain Event and EventAggregator look the same to me, at least for the Domain Event aggregator posted on Udi Dahan's blog. So does it mean that within the application, I will use two EventAggregators, one for the ViewModels and one for the Models. The one used by the ViewModel is still called the EventAggregator, whereas the one used by the Models is called Domain Event.
Does this imply that both the Domain Event used by the Models and the EventAggregator used by the ViewModels are both of the same implementation of EventAggregator, except that they are created as two different instances within the application, ie, two of the same kind of EventAggregators within the application but only used for different purposes? If this is true, since it's the same implementation, why not just use one common EventAggregator for both the ViewModels and Models?