Using MediatR as a mediator
In this section, we are exploring MediatR, an open source mediator implementation.
What is MediatR? Let’s start with its maker’s description from its GitHub repository, which brands it as this:
“Simple, unambitious mediator implementation in .NET”
MediatR is a simple but very powerful tool doing in-process communication through messaging. It supports a request/response flow through commands, queries, notifications, and events, synchronously and asynchronously.
You can install the NuGet package using the .NET CLI: dotnet add package MediatR
.
Now that I have quickly introduced the tool, we are going to explore the migration of our Clean Architecture sample but instead use MediatR to dispatch the StocksController
requests to the core use cases.
Why migrate our Clean Architecture sample? The primary reason we are building the same project using different models is for ease of comparison. It is...