Dormito.DomainEvents 1.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package Dormito.DomainEvents --version 1.0.5                
NuGet\Install-Package Dormito.DomainEvents -Version 1.0.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Dormito.DomainEvents" Version="1.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dormito.DomainEvents --version 1.0.5                
#r "nuget: Dormito.DomainEvents, 1.0.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Dormito.DomainEvents as a Cake Addin
#addin nuget:?package=Dormito.DomainEvents&version=1.0.5

// Install Dormito.DomainEvents as a Cake Tool
#tool nuget:?package=Dormito.DomainEvents&version=1.0.5                

DomainEvents v1.0.5

NuGet version License: MIT CI GitHub Release CodeQL .Net Stardard

Library to help implement transactional events in domain bounded context.

Use 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.

What is a Domain Event?

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.

image

How to Define, Publish and Subscribe to an Event using DomainEvents library?

  1. Define - To implement a domain event, simply derive the event class from IDomainEvent interface.
public class CustomerCreated : IDomainEvent {
        public string Name { get; set; }
}
  1. Publish - To raise the domain event, Inject IPublisher using your favourite IoC container and call the RaiseAsync() method.
  var @event = new CustomerCreated { Name = "Ninja Sha!4h" };
  await _Publisher.RaiseAsync(@event);
  1. Subscribe - To listen to a domain event, implement 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}");
         .....
     }
}
  1. Example - IoC Container Registrations
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>();
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.1 118 4/5/2024
2.0.0 180 6/27/2023
1.0.6 149 5/18/2023
1.0.5 160 5/18/2023
1.0.1 305 11/25/2022