API reference@evolu/commonSchedule › collectWhileScheduleOutput

function collectWhileScheduleOutput<Output>(
  predicate: Predicate<Output>,
): <Input>(
  schedule: Schedule<Output, Input>,
) => Schedule<readonly Output[], Input>;

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

Collects outputs while a predicate is true.

More flexible than collectAllScheduleOutputs — stops collecting when the predicate returns false.

Example

// Collect delays while under 1 second
const smallDelays = collectWhileScheduleOutput((delay: Millis) => delay < 1000)(
  exponential("100ms"),
);
// Outputs: [100], [100, 200], [100, 200, 400], [100, 200, 400, 800], stops