API reference › @evolu/common › Schedule › collectUntilScheduleOutput
function collectUntilScheduleOutput<Output>(
predicate: Predicate<Output>,
): <Input>(
schedule: Schedule<Output, Input>,
) => Schedule<readonly Output[], Input>;
Defined in: packages/common/src/Schedule.ts:1762
Collects outputs until a predicate becomes true.
Mirror of collectWhileScheduleOutput — stops collecting when the predicate returns true.
Collecting until output matches
import {
assertErr,
assertOk,
collectUntilScheduleOutput,
done,
exponential,
testCreateDeps,
type Millis,
} from "@evolu/common";
// Collect delays until the next delay reaches at least one second.
const untilLarge = collectUntilScheduleOutput((delay: Millis) => delay >= 1000)(
exponential("100ms"),
);
const step = untilLarge(testCreateDeps());
step(undefined);
step(undefined);
step(undefined);
assertOk(step(undefined), [[100, 200, 400, 800], 800]);
assertErr(step(undefined), done());