From e72d9975630898741265bb392a952cea5dd34b3d Mon Sep 17 00:00:00 2001 From: TheXamlGuy Date: Sun, 7 Jan 2024 22:38:50 +0000 Subject: [PATCH] handler fix --- Hyperbar/Mediators/Mediator.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Hyperbar/Mediators/Mediator.cs b/Hyperbar/Mediators/Mediator.cs index 1ae56d0..f11d20a 100644 --- a/Hyperbar/Mediators/Mediator.cs +++ b/Hyperbar/Mediators/Mediator.cs @@ -8,7 +8,7 @@ public class Mediator(IServiceProvider provider) : { private readonly ConditionalWeakTable addedHandlers = []; - public async ValueTask PublishAsync(TNotification notification, + public ValueTask PublishAsync(TNotification notification, CancellationToken cancellationToken = default) where TNotification : INotification @@ -24,14 +24,12 @@ public class Mediator(IServiceProvider provider) : } } - if (handlers.Count == 0) + foreach (INotificationHandler handler in handlers) { - } - else if (handlers.Count == 1) - { - await handlers[0].Handle(notification, cancellationToken); + return handler.Handle(notification, cancellationToken); } + return default; } public ValueTask SendAsync(IRequest request,