.Net Library to implement transactional events in domain model.
$ dotnet add package Dormito.DomainEventsUse domain events to explicitly implement side effects of changes within your domain. In other words, and using DDD terminology, use domain events to explicitly implement side effects across multiple aggregates.
An event is something that has happened in the past. A domain event is, something that happened in the domain that you want other parts of the same domain (in-process) to be aware of. The notified parts usually react somehow to the events. The domain events and their side effects (the actions triggered afterwards that are managed by event handlers) should occur almost immediately, usually in-process, and within the same domain. It's important to ensure that, just like a database transaction, either all the operations related to a domain event finish successfully or none of them do.
Figure below shows how consistency between aggregates is achieved by domain events. When the user initiates an order, the Order Aggregate sends an OrderStarted domain event. The OrderStarted domain event is handled by the Buyer Aggregate to create a Buyer object in the ordering microservice (bounded context). Please read Domain Events for more details.

IDomainEvent interface.public class CustomerCreated : IDomainEvent {
public string Name { get; set; }
}
IPublisher using your favourite IoC container and call the RaiseAsync() method. var @event = new CustomerCreated { Name = "Ninja Sha!4h" };
await _Publisher.RaiseAsync(@event);
IHandler<T> interface where T is the event type you intend to handle.public class CustomerCreatedHandler : IHandler<CustomerCreated>
{
public Task HandleAsync(CustomerCreated @event)
{
Console.WriteLine($"Customer created: {@event.Name}");
.....
}
}
public void ConfigureServices(IServiceCollection services)
{
// register publisher with required lifetime.
services.AddTransient<IPublisher, Publisher>();
// register all implemented event handlers.
services.AddTransient<IHandler, CustomerCreatedHandler>();
services.AddTransient<IHandler, OrderReceivedHandler>();
}