[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Schedule](https://evolu.dev/docs/api-reference/common/Schedule) › whenInput

```ts
function whenInput<Input, Output>(
  predicate: Predicate<Input>,
  altSchedule: Schedule<Output, Input>,
): (schedule: Schedule<Output, Input>) => Schedule<Output, Input>;
```

Defined in: [packages/common/src/Schedule.ts:1987](https://github.com/evoluhq/evolu/blob/037c390af081e9944d616ff298a729515c5c5ab7/packages/common/src/Schedule.ts#L1987)

Selects between two schedules based on input.

If [Predicate](https://evolu.dev/docs/api-reference/common/Types/type-aliases/Predicate) returns `true`, uses `altSchedule`; otherwise uses the
base schedule. Useful for implementing error-aware backoff where certain
errors (e.g., throttling) use different delays.

Each branch has independent state. Place combinators such as [take](https://evolu.dev/docs/api-reference/common/Schedule/functions/take)
outside `whenInput` when their state must be shared across both branches.

### Selecting a schedule by input

```ts
import {
  assertErr,
  assertOk,
  done,
  exponential,
  take,
  testCreateDeps,
  whenInput,
  type Millis,
  type Typed,
} from "@evolu/common";

interface MyError extends Typed<"Throttled" | "NetworkError"> {}

// The outer take shares one retry limit across both error branches.
const awsWithThrottling = take(3)(
  whenInput<MyError, Millis>(
    (error) => error.type === "Throttled",
    exponential("1s"),
  )(exponential("100ms")),
);
const step = awsWithThrottling(testCreateDeps());
assertOk(step({ type: "Throttled" }), [1000, 1000]);
assertOk(step({ type: "NetworkError" }), [100, 100]);
assertOk(step({ type: "Throttled" }), [2000, 2000]);
assertErr(step({ type: "NetworkError" }), done());
```