title: Event Aggregation...What exactly is going on?
body: <p>I have often times wondered about it but now that I have encountered a piece of logic that incorporates it, I thought I should go ahead and get some help on deciphering the fundamentals. The problem is as follows, I am looking at a WPF application that is utilizing the Composite Application Library. Within the source of the application I came across the following line of code in the Presentation of a view. For the sake of convinience I will call it Presentation A:</p>
  
  <pre><code>private void OnSomethingChanged(SomeArgumentType arguement)
  {
     UnityImplementation.EventAggregator.GetEvent&lt;EventA&gt;().Publish(null);
  }
  </code></pre>
  
  <p>When I saw the method Publish in the above given method, my gut told me there must be a Subscribe somewhere and in another class, I will call it Presentation B there was the following:</p>
  
  <pre><code>UnityImplementation.EventAggregator.GetEvent(Of EventA).Subscribe(AddressOf OnSomeEventA)
  </code></pre>
  
  <p>There was a private function in the same class called OnSomeEventA that had some logic in it.</p>
  
  <p>My question here is that how is everything wired over here? What exactly is achieved by the 'Publish' 'Subscribe' here? When 'something' changes, how does the compiler know it has to follow the logic in OnSomethingChanged that will 'Publish' an event that is 'Subscribed' by another class where the logic of the event handler has been described? It will be great to understand the underlying wiring of this process.</p>
  
  <p>Thanks</p>