Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

AsyncRequestHandler #68

Closed
space-alien opened this issue Feb 12, 2019 · 2 comments
Closed

AsyncRequestHandler #68

space-alien opened this issue Feb 12, 2019 · 2 comments

Comments

@space-alien
Copy link

space-alien commented Feb 12, 2019

Just wondering if there is any reason not to use MediatR's AsyncRequestHandler which avoids the Unit return type?

https://github.com/jbogard/MediatR/wiki

@jasontaylordev
Copy link
Owner

No reason. I was reviewing the documentation myself and thought this would be much cleaner. I don't really like messing about with the Unit return type either. I'll probably use it in the future.

@jasontaylordev
Copy link
Owner

Just a follow-up, I tried this today, this doesn't work very well. The AsyncRequestHandler is defined as follows:

    public abstract class AsyncRequestHandler<TRequest> : IRequestHandler<TRequest>, IRequestHandler<TRequest, Unit> where TRequest : IRequest
    {
        protected AsyncRequestHandler();

        protected abstract Task Handle(TRequest request, CancellationToken cancellationToken);
    }

You can see the Handle method is protected. Not so easy to unit test.

I'll close this off, however feel free to let me know if you have any suggestions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants