getHandlerFor<TResponse extends Object?> method

RequestHandler<dynamic, Request> getHandlerFor<TResponse extends Object?>(
  1. Request<TResponse> request
)

Returns the registered RequestHandler's for request.

Implementation

RequestHandler getHandlerFor<TResponse extends Object?>(
  Request<TResponse> request,
) {
  final requestType = request.runtimeType;
  final handler = _handlers[requestType];

  assert(
    handler != null,
    'getHandlerFor<$TResponse, $requestType> did not have a registered handler. '
    'Make sure to register the request handler first.',
  );

  assert(
    handler is RequestHandler<TResponse, Request<TResponse>>,
    'The registered handler is of the wrong type got $handler but was '
    'expecting a type of RequestHandler<$TResponse, $requestType>',
  );

  return handler!;
}