send<TRequest, TResponse> method
Implementation
Future<MediatorResultTyped<TResponse>> send<TRequest, TResponse>(
TRequest request) async {
final requestType = request.runtimeType;
final handler = _handlerMapping.getHandlerByType<TResponse>(requestType);
if (handler != null) {
try {
final result = await handler.execute(request);
return MediatorResultTyped.success(result);
} on Exception catch (e) {
return MediatorResultTyped.error(
'Error executing handler for request type ${requestType.toString()} ',
exception: e);
}
}
return MediatorResultTyped.error(
'No handler registered for request type ${requestType.toString()} ',
exception: Exception(
'No handler registered for request type ${requestType.toString()} '));
}