Skip to content

[Feature]: Runtime Notification Dispatch Overload #220

@eneshoxha

Description

@eneshoxha

Title: Add non-generic PublishAsync(INotification) overload for runtime-typed notifications

Labels: enhancement, mediator

Body:

Problem

IMediator.PublishAsync<TNotification> requires the notification type to be known at compile time. There is no runtime-dispatch overload like:

Task PublishAsync(INotification notification, CancellationToken cancellationToken = default);

This makes it impossible to publish notifications when the concrete type is determined at runtime (e.g., deserializing events from a message bus, dispatching domain events from an aggregate root's List<INotification>).

Commands and queries already have this pattern (SendCommandAsync(ICommand<TResult>) and SendQueryAsync(IQuery<TResult>) use reflection-based dispatch).

Proposed Solution

Add to IMediator:

Task PublishAsync(INotification notification, CancellationToken cancellationToken = default);

Implementation in Mediator.cs should follow the same reflection + ConcurrentDictionary<Type, MethodInfo> caching pattern used for commands and queries.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestfeatureThis label is in use for minor version increments
No fields configured for Feature.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions