request<T> method
Future
request<T>(
- T data, {
- List<
String> ? paths, - String? separator,
- Map<
String, String> ? arguments, - 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);
}