API reference@evolu/commonSchedule › whileScheduleOutput

function whileScheduleOutput<Output>(
  predicate: Predicate<Output>,
): <Input>(schedule: Schedule<Output, Input>) => Schedule<Output, Input>;

Defined in: packages/common/src/Schedule.ts:1258

Continues while the output satisfies a predicate.

Stops (returns Err(Done<void>)) when Predicate returns false.

Continuing by output

import {
  assertErr,
  done,
  exponential,
  testCreateDeps,
  whileScheduleOutput,
  type Millis,
} from "@evolu/common";

// Continue while the exponential delay is below five seconds.
const capped = whileScheduleOutput((delay: Millis) => delay < 5000)(
  exponential("1s"),
);
const step = capped(testCreateDeps());
step(undefined);
step(undefined);
step(undefined);
assertErr(step(undefined), done());