Initializes a new instance of the Action
class with a specified name and handler function.
An object containing:
name
: A string to name the action. This name is incorporated into the action's unique identifier.handler
: An ActionFunction from XState designed to execute based on the current machine context and the event that triggered the action.Private
idPrivate
paramsAccesses the handler function defined for this action. This function is invoked by the state machine to perform the action's logic, taking into account the current context and the triggering event.
The ActionFunction configured during the creation of this instance, which processes the state and event to perform the specified action.
Provides the unique identifier of this action instance. The identifier includes the action's name and a UUID, enhancing traceability and uniqueness within a state machine.
A string that serves as the unique identifier of this action instance.
Static
copyClones an existing Action
instance, creating a new instance with the same parameters but a new unique identifier.
The Action
instance to clone.
A new Action
instance that is a copy of the input but with a unique identifier.
Generated using TypeDoc
A generic class for defining actions within an XState state machine context. It encapsulates action logic and associates it with a unique identifier. Actions defined using this class can be used for handling state transitions or performing side effects in response to events in the state machine.
Example usage:
Typeparam
TContext The type of the state context within which the action operates.
Typeparam
TEventData The type of the event within which the action operates.