API reference › @evolu/common › Schedule › resetScheduleAfter
function resetScheduleAfter(
duration:
| DurationLiteral
| (number &
Brand<"NonNaN"> &
Brand<"Finite"> &
Brand<"Int"> &
Brand<"NonNegative"> &
Brand<"LessThan281474976710655"> &
Brand<"Millis"> &
Brand<"Positive">),
): <Output, Input>(
schedule: Schedule<Output, Input>,
) => Schedule<Output, Input>;
Defined in: packages/common/src/Schedule.ts:1343
Resets a running schedule after a period of inactivity.
Before each step, if the time since the previous step is at least duration,
replaces the wrapped schedule with fresh state. Once the wrapped schedule
returns Done, termination is final.
Resetting after inactivity
import {
assertOk,
exponential,
resetScheduleAfter,
testCreateDeps,
} from "@evolu/common";
const backoff = resetScheduleAfter("1m")(exponential("1s"));
const deps = testCreateDeps();
const step = backoff(deps);
assertOk(step(undefined), [1000, 1000]);
deps.time.advance("1m");
assertOk(step(undefined), [1000, 1000]);