As I'm getting further in CQRS using Mediatr I've started to run into situations where I'll need to make a calls to several handlers to process a Web API method and I'm not sure what they best approach is to doing this.
When calling one handler from another is it better to create an instance of the sub-handler directly, or to have a Mediatr instance in the handler to do it? Or, is this a bad pattern and should I only call handlers from the API Controller?
This is mostly coming from refactoring out duplicate code that's used by multiple handler, like a GetUserRolesHandler that would be used in multiple handlers for validating and building the data used to perform their actions.
As I'm getting further in CQRS using Mediatr I've started to run into situations where I'll need to make a calls to several handlers to process a Web API method and I'm not sure what they best approach is to doing this.
When calling one handler from another is it better to create an instance of the sub-handler directly, or to have a Mediatr instance in the handler to do it? Or, is this a bad pattern and should I only call handlers from the API Controller?
This is mostly coming from refactoring out duplicate code that's used by multiple handler, like a GetUserRolesHandler that would be used in multiple handlers for validating and building the data used to perform their actions.