AsyncMediator is a clone of MediatR. Here is the GitHub repo:
The delayed events created using the IMediator are not executed at the end of the use case (command or query) execution.
To execute the deferred events, the IMediator.ExecuteDeferredEvents() method must be called, but how to ensure its execution after each command or query?
Create a wrapper over the IMediator implementation which. We can call it RequestBus. It will:
- send the requested command/query to the
IMediatorinstance; - execute the delayed events by calling the
IMediator.ExecuteDeferredEvents()method.
Create base classes, one for commands and and one for queries, which will execute the delayed events at the end of the Handle() method execution.
Note
See different git branches for each solution.