-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IRequestHandlers vs INotificationHandler #163
Comments
Requests are for:
1 request to 1 handler. Handler may or may not return a value
Notifications are for:
1 notification to n handlers. Handler may not return a value.
In practical terms, requests are "commands", notifications are "events".
Command would be directing MediatR to do something like
"ApproveInvoiceCommand -> ApproveInvoiceHandler". Event would be
notifications, like "InvoiceApprovedEvent ->
SendThankYouEmailToCustomerHandler"
HTH
…On Thu, Apr 27, 2017 at 2:27 PM, Cecil Phillip ***@***.***> wrote:
Please excuse my trivial question, but I'm a little unsure about the major
differences between IRequestHandler<T> and INotificationHandler<T>.
The interface methods looks fairly similar.
- INotificationHandler<T> - void Handle(TNotification notification);
- IRequestHandler<T> - void Handle(TRequest message);
<https://github.com/jbogard/MediatR/blob/master/src/MediatR/INotificationHandler.cs#L14>
(https://github.com/jbogard/MediatR/blob/master/
src/MediatR/IRequestHandler.cs#L30
<https://github.com/jbogard/MediatR/blob/master/src/MediatR/IRequestHandler.cs#L30>
)
They also both seem applicable for fire & forget scenarios. When exactly
would you use notifications over void returning requests? I'm probably
missing something very blatant here.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#163>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGYMiD48W1u2NTwltpqvnwmP_YneIWaks5r0OwGgaJpZM4NKqcy>
.
|
Gotcha. Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please excuse my trivial question, but I'm a little unsure about the major differences between IRequestHandler<T> and INotificationHandler<T>.
The interface methods looks fairly similar.
They also both seem applicable for fire & forget scenarios. When exactly would you use notifications over void returning requests? I'm probably missing something very blatant here.
The text was updated successfully, but these errors were encountered: