Please excuse my trivial question, but I'm a little unsure about the major differences between IRequestHandler 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.
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 notifications@github.com
wrote:
Please excuse my trivial question, but I'm a little unsure about the major
differences between IRequestHandlerand INotificationHandler . The interface methods looks fairly similar.
- INotificationHandler
- void Handle(TNotification notification); - IRequestHandler
- 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
https://github.com/jbogard/MediatR/issues/163, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAGYMiD48W1u2NTwltpqvnwmP_YneIWaks5r0OwGgaJpZM4NKqcy
.
Gotcha. Thanks!
Most helpful comment
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 notifications@github.com
wrote: