API reference@evolu/commonSchedule › elapsed

const elapsed: Schedule<Millis>;

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

A schedule that outputs the total elapsed time since its first step.

Never stops — combine with take or maxElapsed to limit. Useful for tracking how long a retry sequence has been running.

Tracking elapsed time

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

// Track elapsed time alongside each backoff step.
const withTiming = intersectSchedules(exponential("100ms"), elapsed);
assertOk(withTiming(testCreateDeps())(undefined), [[100, 0], 100]);

// Or stop a schedule after 30 seconds of elapsed time.
const timeLimited = whileScheduleOutput((ms: Millis) => ms < 30000)(elapsed);
const deps = testCreateDeps();
const step = timeLimited(deps);
step(undefined);
deps.time.advance("30s");
assertErr(step(undefined), done());