---
url: /api/kiln/functions/runIf.md
---
[Kiln API](../../index.md) / [kiln](../index.md) / runIf

# Function: runIf()

```ts
function runIf(cond, ...items): Gate;
```

Runs the given systems only while `cond` is true: `runIf(inState(Screen, 'playing'), chain(A, B), C)`.
Order works as without it: a gated chain still runs in order, `.after()` still applies. Gates nest
(all conditions must hold). Skipped systems don't read events, so they see them when they run again
only if the events are still alive (two runs of the emitting phase).

## Parameters

| Parameter | Type |
| ------ | ------ |
| `cond` | [`Condition`](../type-aliases/Condition.md) |
| ...`items` | [`Schedulable`](../type-aliases/Schedulable.md)\[] |

## Returns

[`Gate`](../interfaces/Gate.md)
