# when

`import { when } from "destack:simulation/scenario";`

Create a trigger that fires when `predicate` accepts the attempt.

```ds title="when"
export function when(predicate: (&'a readonly Attempt) => boolean, on?: EventKind | undefined): Trigger
```

[language/library/src/simulation/scenario/trigger.ds:93:95](https://github.com/destack-sh/destack/blob/main/language/library/src/simulation/scenario/trigger.ds#L93-L95)
