Skip to content

A super lightweight and free alternative to libraries that provide decoupled, in-process communication.

License

Notifications You must be signed in to change notification settings

henningtandberg/Mando

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mando

A super lightweight and free alternative to libraries that provide decoupled, in-process communication.

Build and Test GitHub License GitHub Release NuGet Version NuGet Downloads


Usage

You can use the package directly or fork this repo and create your own, custom implementation.

Installation

The easiest way to add Mando to your project via NuGet.

Features

The features of this library are limited by design, so that the library will be easier to extend if you decide to fork the repo and create a more custom implementation. The core features are, and will always be:

Single command, single handler

Code Example
internal sealed MyCustomCommand : ICommand;

internal sealed MyCustomCommandHandler : ICommandHandler<MyCustomCommand>
{
    public Task Execute(MyCustomCommand command)
    {
        // Your magic here!
    }
}

Single command, multiple handlers

Code Example
internal sealed MyCustomCommand : ICommand;

internal sealed MyCustomCommandHandlerOne : ICommandHandler<MyCustomCommand>
{
    public Task Execute(MyCustomCommand command)
    {
        // Your magic here!
    }
}

internal sealed MyCustomCommandHandlerTwo : ICommandHandler<MyCustomCommand>
{
    public Task Execute(MyCustomCommand command)
    {
        // And some other magic here!
    }
}

Multiple commands, single handler

Code Example
internal sealed MyCustomCommandOne : ICommand;
internal sealed MyCustomCommandTwo : ICommand;

internal sealed MyCustomCommandHandler :
    ICommandHandler<MyCustomCommandOne>, ICommandHandler<MyCustomCommandTwo>
{
    public Task Execute(MyCustomCommandOne command)
    {
        // Your magic here!
    }
    
    public Task Execute(MyCustomCommandTwo command)
    {
        // Even more magic here!
    }
}

Dependency Injection

services.AddMando(Assembly.GetExecutingAssembly()))

This registers

  • ICommandHandler<TCommand> : All implementations are registered as Scoped
  • IDispatcher as Scoped

Usage

internal sealed class Application(IDispatcher dispatcher) : IApplication
{
    public Task RunAsync() => dispatcher.Dispatch(new DoSomethingCommand());
}

Checkout Mando.Example for a working example.

About

A super lightweight and free alternative to libraries that provide decoupled, in-process communication.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages