> For the complete documentation index, see [llms.txt](https://mars-15.gitbook.io/dispatchito/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mars-15.gitbook.io/dispatchito/basic-functionality/sending-event.md).

# Sending event

Sending event is achieved by calling `DispatchEvent` function and selecting:

1. Topic of the event
2. (Optional) Payload object to pass with the event
3. (Optional) Whether to include parent topics

{% tabs %}
{% tab title="Blueprint" %}

<figure><img src="https://1181272575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfQy1REqz5GdSLZ1Mbpoo%2Fuploads%2F5dtnAsxHT13TnG1qHCbp%2Fimage.png?alt=media&amp;token=d6c792a6-61c7-4991-bd5d-ca1bad2906bc" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="C++" %}

```cpp
UDispatchitoSubsystem* subsystem = GEngine->GetEngineSubsystem<UDispatchitoSubsystem>();

UCustomPayload* payload = NewObject<UCustomPayload>();

bool includeParentTopics = false;

subsystem->DispatchEvent(sender, topic, payload, includeParentTopics);
```

{% endtab %}
{% endtabs %}

#### Topic of the event

A `GameplayTag` based identifier for the event "type". Upon dispatch all subscribers will have their bound callback functions called for the subscriptions made to this topic.

#### Payload

A `UObject` based payload object that can optionally be attached to the event. A reference to this object is passed to each callback function being called.

#### Including parent topics

Due to hierarchical nature of `GameplayTag`, this allows to call subscribers of topics up the hierarchy. E.g., given topic `MyAwesomeGame.SuperTag`, a call to `DispatchEvent` with `bIncludeParentTopics` set to true, would execute subscribers of both `MyAwesomeGame.SuperTag` and `MyAwesomeGame`. This functionally works as a scoped "subscribe to all", allowing for some level of control instead of brute-forcing subscription to all topics and selecting only specific ones in the handler.
