Contents

subscribe(to:_:)

Subscribes to a serializable action event and returns a ActionResult.

Declaration

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

Discussion

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

struct MyAction: BehaviorTreeAction, Codable {
    // ...
}
MyAction.subscribe(to: .updated) { event in
    // Return value is the action result.
    return .success
}

See Also

Subscribing to events