conditionalDelay function

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

Implementation

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