This repository is a sub repository in the SFEOS github organization and is meant to be a building block example repository that SFEOS prototype developers can use to implement a very simple pub/sub event bus system without the overhead of an actual event bus. It uses MediatR, which in turn uses Dependency Injection to register and handle event publishing to subscribers. This repository follows the DDD (Domain Driven Design) Domain Events pattern (you can read more about it here).
Summary of Its Use
First you must add the Event class to the Dependency Injection Container. The Event class can hold any data that needs to be published to the subscribers.
Once you have the Event class added you can publish a message to any subscriber class(es) that might be interested in the event.
_mediator.Publish(newScannerEventCompleted("Some result from the scan."));
Any service or aggregate can subscribe to the event by inheriting from the NotificationHandler and then implementing the HandleCore method.
publicclassNotificationService:NotificationHandler<ScannerEventCompleted>{protectedoverridevoidHandleCore(ScannerEventCompletedmessage){// do anything that needs done after the event happened.}}