> For the complete documentation index, see [llms.txt](https://pahutyakv.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pahutyakv.gitbook.io/docs/delayed/event-based-actions.md).

# Event-Based Actions

The `Delayed.Event` module performs actions when the Invoke method is called on a passed event. They are ideal for responding to game events.

***

### <mark style="color:$success;">Methods</mark>

<details>

<summary><strong>On(UnityEvent unityEvent, Action callback)</strong></summary>

Executes a `callback` when a `UnityEvent` is invoked.

{% code overflow="wrap" %}

```csharp
Delayed.Event.OnUnityEvent(OnLevelCompleted, () => Debug.Log("On Level Completed!"));
```

{% endcode %}

</details>

<details>

<summary><strong>On(Func getEvent, Action setEvent, Action callback)</strong></summary>

Executes a `callback` when a `C# event (Action)` is invoked.

{% code overflow="wrap" %}

```csharp
Delayed.Event.OnEvent(() => OnLevelFailed, x => OnLevelFailed = x, () => Debug.Log("On Level Failed!"));
```

{% endcode %}

</details>

***

### <mark style="color:$primary;">Notes</mark>

* It differs from the usual subscription method in that it automatically unsubscribes after the first execution
* You can automatically set the number of repetitions before unsubscribing using the `Loop` method.
* Ideal for monitoring dynamic game triggers or events.
