Upgrading MediatR 4 to 5
Breaking4.1.0 → 5.1.0Breaking4Changed1
BreakingUpgrade verdict
4 breaking changes.
In plain terms
- When MediatR runs several handlers or processors at once, it now waits for each one to finish in order instead of starting them all together.
- Publishing a notification and the request pre and post processors now run their tasks one after another rather than all at once.
- The separate factory delegate types are replaced by one shared delegate type, so code that used the old delegate types must be updated.
- Requests and handlers that used the non-generic void versions now derive from the Unit-based versions, which can affect existing implementations.
Must act Top 3 of 4 that need code or config changes
What you must change
Breaking4
Changes the default behavior for awaiting an enumerable of Task from Task.WhenAll to sequential foreach awaiting.
Task.WhenAllAwaiting enumerables now uses a foreach for Mediator.Publish, RequestPreProcessorBehavior and RequestPostProcessorBehavior.
Mediator.PublishRequestPreProcessorBehaviorRequestPostProcessorBehaviorConsolidates interfaces and factories so the factory delegates are now a single ServiceFactory delegate.
ServiceFactoryThe void IRequest interface now inherits IRequest<Unit>, and IRequestHandler<T> inherits IRequestHandler<T, Unit>.
IRequestIRequest<Unit>IRequestHandler<T>IRequestHandler<T, Unit>Unit