API reference › @evolu/common › Schedule › untilScheduleOutput
function untilScheduleOutput<Output>(
predicate: Predicate<Output>,
): <Input>(schedule: Schedule<Output, Input>) => Schedule<Output, Input>;
Defined in: packages/common/src/Schedule.ts:1307
Continues until the output satisfies a predicate.
Stops (returns Err(Done<void>)) when Predicate returns true.
Stopping by output
import {
assertErr,
done,
exponential,
testCreateDeps,
untilScheduleOutput,
type Millis,
} from "@evolu/common";
// Stop once the exponential delay reaches at least one second.
const limited = untilScheduleOutput((delay: Millis) => delay >= 1000)(
exponential("100ms"),
);
const step = limited(testCreateDeps());
step(undefined);
step(undefined);
step(undefined);
step(undefined);
assertErr(step(undefined), done());