33 lines
600 B
Go
33 lines
600 B
Go
package fsm
|
|
|
|
// Result defines a possible outcome for a given FSM Transition.
|
|
type Result struct {
|
|
/**
|
|
* The return value of the event handler.
|
|
*
|
|
* @var mixed
|
|
*/
|
|
Return any
|
|
|
|
/**
|
|
* State is the state to which the FSM must change when handling this Result.
|
|
*
|
|
* If empty, do not change the current state.
|
|
*/
|
|
State
|
|
|
|
/**
|
|
* Action is the name of an event to be fired after the state change has been applied.
|
|
*
|
|
* @var string
|
|
*/
|
|
Action Event
|
|
}
|
|
|
|
func NewResult(ret any, state State, action Event) *Result {
|
|
return &Result{
|
|
Action: action,
|
|
Return: ret,
|
|
State: state,
|
|
}
|
|
}
|