API reference › @evolu/common › Schedule › intersectSchedules
function intersectSchedules<OutputA, OutputB, Input>(
a: Schedule<OutputA, Input>,
b: Schedule<OutputB, Input>,
): Schedule<[OutputA, OutputB], Input>;
Defined in: packages/common/src/Schedule.ts:1856
Combines two schedules with AND semantics.
Continues only while both schedules want to continue. Uses the maximum delay.
Combining constraints with AND
import {
assertErr,
assertOk,
done,
exponential,
forever,
intersectSchedules,
maxElapsed,
take,
testCreateDeps,
} from "@evolu/common";
// Retry at most 5 times and only within 30 seconds.
const deps = testCreateDeps();
const step = intersectSchedules(
take(5)(exponential("1s")),
maxElapsed("30s")(forever),
)(deps);
assertOk(step(undefined), [[1000, 0], 1000]);
deps.time.advance("30s");
assertErr(step(undefined), done());