API reference@evolu/commonSchedule › fixed

function fixed(interval: Duration): Schedule<number>;

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

Fixed interval schedule aligned to time windows.

Recurs on a fixed interval, outputting the repetition count (0, 1, 2, ...). Unlike spaced, which waits a duration after each execution, fixed maintains a consistent cadence from the first schedule step.

If execution falls behind by one or more intervals, missed recurrences happen immediately until the schedule catches up to the original cadence. Use windowed to skip missed recurrences instead.

Maintaining a fixed cadence

import { assertOk, fixed, take, testCreateDeps } from "@evolu/common";

// A bounded health check and an unbounded cron-like cadence.
const healthCheck = take(10)(fixed("5s"));
const cronLike = fixed("1m");

const healthDeps = testCreateDeps();
const healthStep = healthCheck(healthDeps);
assertOk(healthStep(undefined), [0, 5000]);
healthDeps.time.advance("3s");
assertOk(healthStep(undefined), [1, 2000]);
assertOk(cronLike(testCreateDeps())(undefined), [0, 60000]);