request<T> method

  1. @override
Future request<T>(
  1. T data, {
  2. List<String>? paths,
  3. String? separator,
  4. Map<String, String>? arguments,
  5. Duration? timeout,
})
override

Sends a request and waits for the result of a handler.

Wildcard paths are not supported: * and > throw EventBusException. When no handler is registered the returned future fails with NoHandlerException. Use fire when no answer is expected.

Implementation

@override
Future<dynamic> request<T>(T data,
    {List<String>? paths,
    String? separator,
    Map<String, String>? arguments,
    Duration? timeout}) async {
  if (isDisposed) {
    throw StateError('EventBusIsolate is disposed');
  }
  if (!_ready) {
    throw StateError(
        'EventBusIsolate is not initialized: await waitInit before request');
  }
  _rejectWildcardPaths(paths, 'request');
  var dto = EventDTO<T>(data,
      paths: paths, arguments: arguments, separator: separator);
  final future = _link.request(dto);
  return timeout == null ? await future : await future.timeout(timeout);
}