conditionalDelay function

PollStrategy conditionalDelay(
  1. PollPredicate<bool> condition,
  2. int timeInMsec
)

Implementation

PollStrategy conditionalDelay(PollPredicate<bool> condition, int timeInMsec) {
  return (
    Principal canisterId,
    RequestId requestId,
    RequestStatusResponseStatus status,
  ) async {
    if (await condition(canisterId, requestId, status)) {
      final c = Completer();
      Future.delayed(Duration(milliseconds: timeInMsec), c.complete);
      return c.future;
    }
  };
}