Can one handler call another MediatR request? #1037
Unanswered
grosch-intl
asked this question in
Q&A
Replies: 1 comment
-
Hi @grosch-intl Technically, it is possible to have a "chain" of requests as you mentioned.
In general, I think that, as always in programming, the correct answer depends on how you implement the flow and what your fault tolerance requirements are. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've seen things saying not to have one handler call another, and I'm not quite sure why. For example, lets say I have a command to generate the documents related to a checklist. Then I have multiple other commands to generate distinct checklist types. But all of them need those same documents. So within each GenerateChecklistTypeXyzHandler I inject IMediator and then the Handle method does something like
checklist.Documents = await mediator.Send(new GenerateDocuments(), cancellationToken);
and then sends the newly generated checklist as the return.Is there a better way to handle this?
Beta Was this translation helpful? Give feedback.
All reactions