Skip to content

🔀 FluentMediator is an unobtrusive library that allows developers to build custom pipelines for Commands, Queries and Events.

License

Notifications You must be signed in to change notification settings

xgame92/FluentMediator

 
 

Repository files navigation

FluentMediator

Build Status All Contributors GitHub issues GitHub pull requests

🔀 We will not require you to implement framework interfaces or to add dependencies to your domain events and 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:

services.AddFluentMediator(builder => {
    builder.On<PingRequest>().Pipeline()
        .Call<IPingHandler>((handler, request) => handler.MyMethod(request))
        .Call<IPingHandler>((handler, request) => handler.MyLongMethod(request))
        .Return<PingResponse, IPingHandler>(
            (handler, request) => handler.MyOtherMethod(request)
        );
});

Then you are able to use the injected IMediator interface.

Publishing Events

// Puts the message in the pipeline, calls three handlers.
mediator.Publish<PingRequest>(ping);

Sending Commands and Queries

// Calls the three handlers then get the response from `MyOtherMethod(PingRequest)`.
PingResponse response = mediator.Send<PingResponse>(new PingRequest("Ping"));
Console.WriteLine(response.Message); // Prints "Pong"

Why

When designing Event-Driven applications we often need to publish events from the infrastructure layer into your domain event handlers. We do not want frameworks dependencies to leak into our model then FluentMediator was born.

Contributors

Ivan Paulovich
Ivan Paulovich

💻 🎨 ⚠️
Joakim Carselind
Joakim Carselind

👀 🤔

Please contribute with Issues, Wiki and Samples.

About

🔀 FluentMediator is an unobtrusive library that allows developers to build custom pipelines for Commands, Queries and Events.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%