Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ivanpaulovich/fluentmediator
:twisted_rightwards_arrows: FluentMediator is an unobtrusive library that allows developers to build custom pipelines for Commands, Queries and Events.
https://github.com/ivanpaulovich/fluentmediator
chain-methods chain-of-responsibility craftmanship csharp ddd-cqrs dotnet-core event-driven event-handlers event-sourcing fluent-design fluent-interface mediator-pattern message-bus pipeline-framework pipelines tdd
Last synced: 3 months ago
JSON representation
:twisted_rightwards_arrows: FluentMediator is an unobtrusive library that allows developers to build custom pipelines for Commands, Queries and Events.
- Host: GitHub
- URL: https://github.com/ivanpaulovich/fluentmediator
- Owner: ivanpaulovich
- License: apache-2.0
- Created: 2019-10-06T00:53:31.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-04T18:55:07.000Z (almost 5 years ago)
- Last Synced: 2024-07-31T21:53:32.346Z (6 months ago)
- Topics: chain-methods, chain-of-responsibility, craftmanship, csharp, ddd-cqrs, dotnet-core, event-driven, event-handlers, event-sourcing, fluent-design, fluent-interface, mediator-pattern, message-bus, pipeline-framework, pipelines, tdd
- Language: C#
- Homepage: http://paulovich.net/FluentMediator/
- Size: 1.14 MB
- Stars: 192
- Watchers: 10
- Forks: 17
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE
Awesome Lists containing this project
README
# FluentMediator
[![Build Status](https://ivanpaulovich.visualstudio.com/FluentMediator/_apis/build/status/ivanpaulovich.FluentMediator?branchName=master)](https://ivanpaulovich.visualstudio.com/FluentMediator/_build/latest?definitionId=24&branchName=master) [![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors) ![GitHub issues](https://img.shields.io/github/issues/ivanpaulovich/FluentMediator) ![GitHub pull requests](https://img.shields.io/github/issues-pr/ivanpaulovich/FluentMediator) ![NuGet](https://buildstats.info/nuget/FluentMediator):twisted_rightwards_arrows: We will not require you to add dependencies into your domain or to implement frameworks interfaces in your event handlers. Finally a really loosely coupled mediator library was born.
## Install
```
Install-Package FluentMediator
```For seameless .NET Core integration:
```
Install-Package FluentMediator.Microsoft.Extensions.DependencyInjection
```## How
Setup your events and pipelines using depedency injection. You can be very creative here! It supports async methods and cancellable tokens parameters, you could append multiple steps select one to return a message. An example:
```c#
services.AddFluentMediator(builder => {
builder.On().Pipeline()
.Call((handler, request) => handler.MyMethod(request))
.Call((handler, request) => handler.MyLongMethod(request))
.Return(
(handler, request) => handler.MyOtherMethod(request)
);
});
```Then you are able to use the injected `IMediator` interface.
### Publishing Events
```c#
// Puts the message in the pipeline, calls three handlers.
mediator.Publish(ping);
```### Sending Commands and Queries
```c#
// Calls the three handlers then get the response from `MyOtherMethod(PingRequest)`.
PingResponse response = mediator.Send(new PingRequest("Ping"));
Console.WriteLine(response.Message); // Prints "Pong"
```## Why
When designing *CQRS* or *Event-Driven* applications we need to publish events from the infrastructure layer into the *domain event handlers*. We do not want framework dependencies leaking out to the Model then **FluentMediator** was born.
## Contributors
Ivan Paulovich
💻 🎨 ⚠️
Joakim Carselind
👀 🤔
Vaggelis Mparmpas
⚠️
Please contribute with [Issues](https://github.com/ivanpaulovich/FluentMediator/issues), [Wiki](https://github.com/ivanpaulovich/FluentMediator/wiki) and [Samples](https://github.com/ivanpaulovich/FluentMediator/tree/master/samples).