Help with Using Schedule Policies for Retrying with Intervals

Struggling to understand how to use the schedule policies.
I am trying to check if some data exists, and as long as the data can't be found, we keep repeating every 1000ms, 30 times max.
Here is my (apparently incorrect) attempt:

  const MAX_ATTEMPTS = 30;
  const INTERVAL_MS = 1000;
  const policy = Schedule.intersect(
    Schedule.untilInput((purchaseExists: boolean) => purchaseExists),
    Schedule.recurs(MAX_ATTEMPTS),
    Schedule.fixed(INTERVAL_MS),
  );
  const program = pipe(
    // checking if purchase data exists
    checkPurchaseExists(purchaseId),
    // retrying 30 times with 1000ms interval if can't be found
    E.retry(policy),
  );
Was this page helpful?