<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/EntityAction/subscribe(to:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation12EntityActionPAAE9subscribe2to_yAA0D9EventTypeV_yAA0dG0VyxGctFZ::OverloadGroup"
  },
  "title" : "subscribe(to:_:)"
}
-->

# subscribe(to:_:)

Subscribes to an action event.

```
@MainActor @preconcurrency static func subscribe(to eventType: ActionEventType, _ handler: @escaping @MainActor (ActionEvent<Self>) -> Void)
```

## Discussion

For example, you can call this method to subscribe to the update event,
which the system calls each frame it evaluates the action:

```swift
struct MyAction: EntityAction {
    ...
}
MyAction.subscribe(to: .updated) { event in
    // RealityKit calls this closure in lock step as it
    // processes each animation frame.
}
```

---

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)