A simple event notifier to pub sub between Domain driven layers
use it with few simple steps:
-
Simply register the event notifier on the container in the setup file using services.AddEventNotifier()
-
Create a notification that is inherited from EventNotifier.Notification or just use Notification it self.
-
Create a subscriber on that Notification:
notifier.Subscribe((SendHelloWorld notification) => { Console.WriteLine(notification.Data); });
-
Inject IEventNotifier and publish your message to the world!
private readonly IEventNotifier _eventNotifier; public MicrosvcService(IEventNotifier eventNotifier) { _eventNotifier = eventNotifier; } public void SayHelloWorld() { _eventNotifier.Publish(new SendHelloWorld { Data = "hello my dear world" }); }