API reference › @evolu/common › Schedule › unionSchedules
function unionSchedules<OutputA, OutputB, Input>(
a: Schedule<OutputA, Input>,
b: Schedule<OutputB, Input>,
): Schedule<OutputA | OutputB, Input>;
Defined in: packages/common/src/Schedule.ts:1910
Combines two schedules with OR semantics.
Continues while either schedule wants to continue. Uses the minimum delay.
Combining constraints with OR
import {
assertErr,
assertOk,
done,
spaced,
take,
testCreateDeps,
unionSchedules,
} from "@evolu/common";
// The second policy keeps the union alive after the first one stops.
const either = unionSchedules(
take(1)(spaced("100ms")),
take(2)(spaced("200ms")),
);
const step = either(testCreateDeps());
assertOk(step(undefined), [100, 100]);
assertOk(step(undefined), [200, 200]);
assertErr(step(undefined), done());