<!--
{
  "availability" : [
    "tvOS: 9.0.0 - 18.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "TVMLKit",
  "identifier" : "/documentation/TVMLKit/TVViewElement/dispatchEvent(type:canBubble:cancellable:extraInfo:completion:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "TVMLKit"
    ],
    "preciseIdentifier" : "c:objc(cs)TVViewElement(im)dispatchEventOfType:canBubble:cancellable:extraInfo:completion:"
  },
  "title" : "dispatchEvent(type:canBubble:cancellable:extraInfo:completion:)"
}
-->

# dispatchEvent(type:canBubble:cancellable:extraInfo:completion:)

Dispatches an event of a specific type to the JavaScript file.

```
func dispatchEvent(type: TVElementEventType, canBubble: Bool, cancellable isCancellable: Bool, extraInfo: [String : Any]?, completion: (@Sendable (Bool, Bool) -> Void)? = nil)
```

## Parameters

`type`

The type of TV element to dispatch. For possible values see [`TVElementEventType`](/documentation/TVMLKit/TVElementEventType).

`canBubble`

A flag that indicates an event is dispatched on the target’s parent nodes after the event has been dispatched on the target.

`isCancellable`

A flag to indicate whether the event can be cancelled.

`extraInfo`

Extra properties that need to be exposed in the event object.

`completion`

A block object to be executed when the dispatch call is complete. This block has no return value and takes two Boolean arguments that indicate whether or not the event has been dispatched and whether it was canceled. This parameter may be NULL.

## Discussion

> Important:
> You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration:
> 
> ```swift
> func dispatchEvent(type: TVElementEventType, canBubble: Bool, cancellable isCancellable: Bool, extraInfo: [String : Any]?) async -> (Bool, Bool)
> ```
> 
> For information about concurrency and asynchronous code in Swift, see <doc://com.apple.documentation/documentation/Swift/calling-objective-c-apis-asynchronously>.

Use this method to dispatch events from views and view controllers to JavaScript.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)