ask method
Asks the handler named id in the first isolate and completes with
its answer. Fails with a StateError when no handler has that id,
and with the handler's error (as text, from another isolate) when it
throws.
Implementation
Future<Object?> ask(String id, [Object? request]) async {
final remote = PrimaryIsolate.remote;
if (remote != null) {
return await remote(id, request);
}
for (final handler in handlers) {
if (handler.id == id) {
return await handler.handle(request);
}
}
throw StateError(
'No PrimaryIsolateHandler bean answers "$id" in '
'${IsolateInfo.current.name}',
);
}