ActionHandlerProtocol
protocol · iOS 18.0+ · SDK 27.1
protocol ActionHandlerProtocolThe base protocol for action handlers. One of two approaches can be taken when subscribing to, and responding to action events. Which approach is taken is dictated by complexity of the action, and user preference. The simplest approach is to process action events using an external closure. This saves having to define a formal handler for the action. For example: ```swift struct MyAction: EntityAction { ... } MyAction.subscribe(to: .started) { event in let action = event.action // Do something with the action. } ``` The other approach is to use a formal handler. This requires defining a structure for the handler that conforms to the `ActionHandlerProtocol` and registering the handler so it can be instantiated when the action animation is played. It is only necessary to define the event functions for the event types that one wishes to respond to. For example: ```swift struct MyAction: EntityAction { } struct MyActionHandler: ActionHandlerProtocol { typealias ActionType = MyAction // Application data can be stored within the handler. var applicationData: ApplicationData // Customizable init init(action: MyAction, player: Entity, currentLevel: Int) { ... } // Process start events mutating func actionStarted(event: EventType) { } } MyActionHandler.register { event in // Create the handler. return MyActionHandler(applicationData: appData) } ```
Members (0)
This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.
Skipped declarations
9 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
ActionHandlerProtocol.actionStarted(event:)
The iOS SDK compiler rejected this binding: cannot access type alias 'EventType' from 'ActionHandlerProtocol'; use a concrete type or generic parameter base instead
ActionHandlerProtocol.actionUpdated(event:)
The iOS SDK compiler rejected this binding: cannot access type alias 'EventType' from 'ActionHandlerProtocol'; use a concrete type or generic parameter base instead
ActionHandlerProtocol.actionEnded(event:)
The iOS SDK compiler rejected this binding: cannot access type alias 'EventType' from 'ActionHandlerProtocol'; use a concrete type or generic parameter base instead
ActionHandlerProtocol.actionSkipped(event:)
The iOS SDK compiler rejected this binding: cannot access type alias 'EventType' from 'ActionHandlerProtocol'; use a concrete type or generic parameter base instead
ActionHandlerProtocol.actionPaused(event:)
The iOS SDK compiler rejected this binding: cannot access type alias 'EventType' from 'ActionHandlerProtocol'; use a concrete type or generic parameter base instead
ActionHandlerProtocol.actionResumed(event:)
The iOS SDK compiler rejected this binding: cannot access type alias 'EventType' from 'ActionHandlerProtocol'; use a concrete type or generic parameter base instead
ActionHandlerProtocol.actionTerminated(event:)
The iOS SDK compiler rejected this binding: cannot access type alias 'EventType' from 'ActionHandlerProtocol'; use a concrete type or generic parameter base instead
ActionHandlerProtocol.register(_:)
callback cannot propagate synchronous failure
ActionHandlerProtocol.register(_:)
callback cannot propagate synchronous failure