An open API service indexing awesome lists of open source software.

https://github.com/simplify9/domainevents

A package that handles Domain events
https://github.com/simplify9/domainevents

Last synced: about 1 year ago
JSON representation

A package that handles Domain events

Awesome Lists containing this project

README

          

[![Build Status](https://dev.azure.com/simplify9/Github%20Pipelines/_apis/build/status/simplify9.EfCoreExtensions?branchName=master)](https://dev.azure.com/simplify9/Github%20Pipelines/_build/latest?definitionId=168&branchName=master)

![Azure DevOps tests](https://img.shields.io/azure-devops/tests/Simplify9/Github%20Pipelines/168?style=for-the-badge)

| **Package** | **Version** |
| :----------------:|:----------------------:|
|```SimplyWorks.DomainEvents```| ![Nuget](https://img.shields.io/nuget/v/SimplyWorks.DomainEvents?style=for-the-badge)
|```SimplyWorks.PrimitiveTypes```| ![Nuget](https://img.shields.io/nuget/v/SimplyWorks.PrimitiveTypes?style=for-the-badge)

## Introduction
[*DomainEvents*](https://www.nuget.org/packages/SimplyWorks.DomainEvents/) is a package that handles your events. When you dispatch an event, *DomainEvents* finds its relevant handlers and runs them.
Define the relevant handles by writing classes that implement the **IHandle** interface from [PrimitiveTypes](https://www.nuget.org/packages/SimplyWorks.PrimitiveTypes/).

## Getting Started
To use *DomainEvents*, you will require the [`PrimitiveTypes`](https://github.com/simplify9/PrimitiveTypes) library.

### *DomainEvents* Setup

```csharp
public static class IServiceCollectionExtensions
{
public static IServiceCollection AddDomainEvents(this IServiceCollection serviceCollection, params Assembly[] assemblies)
{
if (assemblies.Length == 0) assemblies = new Assembly[] { Assembly.GetCallingAssembly() };

serviceCollection.Scan(scan => scan
.FromAssemblies(assemblies)
.AddClasses(classes => classes.AssignableTo(typeof(IHandle<>)))
.AsImplementedInterfaces().WithScopedLifetime());

serviceCollection.AddScoped();

return serviceCollection;
}

}
```
## Getting support 👷
If you encounter any bugs, don't hesitate to submit an [issue](https://github.com/simplify9/DomainEvents/issues). We'll get back to you promptly!