wait method

Future<AgentSnapshot<State>> wait({
  1. Duration interval = const Duration(seconds: 1),
})

Resolves when the task reaches a terminal state.

Implementation

Future<AgentSnapshot<State>> wait({
  Duration interval = const Duration(seconds: 1),
}) async {
  AgentSnapshot<State>? last;
  await for (final snap in poll(interval: interval)) {
    last = snap;
  }
  if (last == null) {
    throw StateError('Detached task $snapshotId did not produce a snapshot.');
  }
  return last;
}