Coder Social home page Coder Social logo

bubdm / fluentmediator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ivanpaulovich/fluentmediator

0.0 0.0 0.0 1.17 MB

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

Home Page: http://paulovich.net/FluentMediator/

License: Apache License 2.0

C# 100.00%

fluentmediator's Introduction

FluentMediator

Build Status All Contributors GitHub issues GitHub pull requests NuGet

๐Ÿ”€ 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:

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 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
Ivan Paulovich

๐Ÿ’ป ๐ŸŽจ โš ๏ธ
Joakim Carselind
Joakim Carselind

๐Ÿ‘€ ๐Ÿค”
Vaggelis Mparmpas
Vaggelis Mparmpas

โš ๏ธ

Please contribute with Issues, Wiki and Samples.

fluentmediator's People

Contributors

allcontributors[bot] avatar ivanpaulovich avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.