result.go 600 B

123456789101112131415161718192021222324252627282930313233
  1. package fsm
  2. // Result defines a possible outcome for a given FSM Transition.
  3. type Result struct {
  4. /**
  5. * The return value of the event handler.
  6. *
  7. * @var mixed
  8. */
  9. Return any
  10. /**
  11. * State is the state to which the FSM must change when handling this Result.
  12. *
  13. * If empty, do not change the current state.
  14. */
  15. State
  16. /**
  17. * Action is the name of an event to be fired after the state change has been applied.
  18. *
  19. * @var string
  20. */
  21. Action Event
  22. }
  23. func NewResult(ret any, state State, action Event) *Result {
  24. return &Result{
  25. Action: action,
  26. Return: ret,
  27. State: state,
  28. }
  29. }