From 053a7a6c4eff327e2c0ee092d473b696b8661f64 Mon Sep 17 00:00:00 2001 From: mehdihadeli Date: Fri, 28 Oct 2022 22:06:40 +0330 Subject: [PATCH] add registrations cleanup --- mediatr.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mediatr.go b/mediatr.go index caad0e9..db93573 100644 --- a/mediatr.go +++ b/mediatr.go @@ -94,6 +94,14 @@ func RegisterNotificationHandlers[TEvent any](handlers ...NotificationHandler[TE return nil } +func ClearRequestRegistrations() { + requestHandlersRegistrations = map[reflect.Type]interface{}{} +} + +func ClearNotificationRegistrations() { + notificationHandlersRegistrations = map[reflect.Type][]interface{}{} +} + // Send the request to its corresponding request handler. func Send[TRequest any, TResponse any](ctx context.Context, request TRequest) (TResponse, error) { requestType := reflect.TypeOf(request)