API reference@evolu/commonSchedule › tapScheduleOutput

function tapScheduleOutput<Output>(
  f: (output: Output) => void,
): <Input>(schedule: Schedule<Output, Input>) => Schedule<Output, Input>;

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

Executes a side effect for every output without altering the schedule.

Useful for logging, monitoring, or debugging without changing schedule behavior.

Observing schedule output

import {
  assertEqual,
  exponential,
  retryStrategyAws,
  tapScheduleOutput,
  testCreateDeps,
  type Millis,
} from "@evolu/common";

// Log each delay for debugging.
const messages: Array<string> = [];
const logged = tapScheduleOutput((delay: Millis) => {
  messages.push(`Next delay: ${delay}ms`);
})(exponential("100ms"));

// Track the preset's pre-jitter delay candidates without changing it.
const recordedCandidates: Array<Millis> = [];
const tracked = tapScheduleOutput((candidate: Millis) => {
  recordedCandidates.push(candidate);
})(retryStrategyAws);
const deps = testCreateDeps();
logged(deps)(undefined);
tracked(deps)(undefined);

assertEqual(messages, ["Next delay: 100ms"]);
assertEqual(recordedCandidates, [50]);