## Reactive.EventAggregator
This is an update of a blog post from José F. Romaniello about using Reactive Extensions to implement an event aggregator. source
To install it, just run this from the Package Manager Console:
Install-Package Reactive.EventAggregator
Three reasons:
// arrange
var eventWasRaised = false;
var eventPublisher = new EventAggregator();
// act
eventPublisher.GetEvent<SampleEvent>()
.Subscribe(se => eventWasRaised = true);
eventPublisher.Publish(new SampleEvent());
// assert
eventWasRaised.ShouldBe(true);
// arrange
var eventWasRaised = false;
var eventPublisher = new EventAggregator();
// act
var subscription = eventPublisher.GetEvent<SampleEvent>()
.Subscribe(se => eventWasRaised = true);
subscription.Dispose();
eventPublisher.Publish(new SampleEvent());
// assert
eventWasRaised.ShouldBe(false);
// arrange
var eventWasRaised = false;
var eventPublisher = new EventAggregator();
// act
eventPublisher.GetEvent<SampleEvent>()
.Where(se => se.Status == 1)
.Subscribe(se => eventWasRaised = true);
eventPublisher.Publish(new SampleEvent { Status = 1 });
// assert
eventWasRaised.ShouldBe(true);