[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) › unfoldSchedule

```ts
function unfoldSchedule<State>(
  initial: State,
  next: (state: State) => State,
): Schedule<State>;
```

Defined in: [packages/common/src/Schedule.ts:541](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/Schedule.ts#L541)

Creates a schedule by unfolding a state.

Each step outputs the current state and computes the next state using the
provided function. Never stops — combine with [take](https://evolu.dev/docs/api-reference/common/Schedule/functions/take) or
[maxElapsed](https://evolu.dev/docs/api-reference/common/Schedule/functions/maxElapsed) to limit.

### Example

```ts
// Counter: 0, 1, 2, 3, ...
const counter = unfoldSchedule(0, (n) => n + 1);

// Custom backoff: 100, 150, 225, 338, ... (×1.5 each time)
const customBackoff = unfoldSchedule(100, (delay) => Math.round(delay * 1.5));

// State machine
type Phase = "init" | "warmup" | "active";
const phases = unfoldSchedule<Phase>("init", (phase) => {
  switch (phase) {
    case "init":
      return "warmup";
    case "warmup":
      return "active";
    case "active":
      return "active";
  }
});
```