File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -160,6 +160,22 @@ It's also possible to use an event name as action.
160160
161161```
162162
163+ ### Invoke actions
164+
165+ States can also declare ** invoke** callbacks — background work that is spawned when the
166+ state is entered and cancelled when it is exited. Like ` enter ` and ` exit ` , invoke supports
167+ all three binding patterns:
168+
169+ - ** Naming convention:** ` on_invoke_<state_id>() `
170+ - ** Inline parameter:** ` State(invoke=callable) `
171+ - ** Decorator:** ` @state.invoke `
172+
173+ ``` {seealso}
174+ Invoke handlers run outside the main processing loop (in threads or executors) and have
175+ their own completion and error events. See {ref}`invoke` for the full execution model,
176+ cancellation semantics, and advanced patterns like `IInvoke` and `invoke_group`.
177+ ```
178+
163179## Transition actions
164180
165181For each {ref}` events ` , you can register ` before ` , ` on ` , and ` after ` callbacks.
@@ -374,6 +390,10 @@ Actions registered on the same group don't have order guaranties and are execute
374390 - `on_enter_state()`, `on_enter_<state.id>()`
375391 - `destination`
376392 - Callbacks declared in the destination state.
393+ * - Invoke
394+ - `on_invoke_state()`, `on_invoke_<state.id>()`
395+ - `destination`
396+ - Background work spawned after entering the state. See {ref}`invoke`.
377397* - After
378398 - `after_<event>()`, `after_transition()`
379399 - `destination`
Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ Invoke is a first-class callback group, just like `enter` and `exit`. This means
2828convention naming (` on_invoke_<state> ` ), decorators (` @state.invoke ` ), inline callables,
2929and the full {ref}` SignatureAdapter <actions> ` dependency injection all work out of the box.
3030
31+ See the {ref}` actions ` page for how invoke fits into the overall
32+ callback {ref}` Ordering ` and the available
33+ {ref}` dependency injection <dynamic-dispatch> ` parameters.
34+
3135## Quick start
3236
3337The simplest invoke is a plain callable passed to the ` invoke ` parameter. Here we read a
@@ -73,7 +77,8 @@ keyword argument in callbacks on the target state.
7377
7478## Naming conventions
7579
76- Like ` on_enter_<state> ` and ` on_exit_<state> ` , invoke supports naming conventions:
80+ Like ` on_enter_<state> ` and ` on_exit_<state> ` , invoke supports naming conventions
81+ (see {ref}` State actions ` for the general pattern):
7782
7883- ` on_invoke_state ` — generic, called for every state with invoke
7984- ` on_invoke_<state_id> ` — specific to a state
108113
109114## Decorator syntax
110115
111- Use the ` @state.invoke ` decorator:
116+ Use the ` @state.invoke ` decorator (same pattern as ` @state.enter ` and ` @state.exit ` —
117+ see {ref}` Bind state actions using decorator syntax ` ):
112118
113119``` py
114120>> > config_file = Path(tempfile.mktemp(suffix = " .txt" ))
You can’t perform that action at this time.
0 commit comments