Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RunningState ¶
RunningState 是状态机的另一个状态
func NewRunningState ¶
func NewRunningState[T any]() *RunningState[T]
type StartState ¶
StartState 是状态机的一个具体状态
func NewStartState ¶
func NewStartState[T any]() *StartState[T]
type State ¶
type State[T any] interface { Enter(data T) Exit(data T) Handle(event string, data T) (State[T], bool) }
State 接口定义了状态的基本行为
type StateMachine ¶
StateMachine 实现了状态机
func NewStateMachine ¶
func NewStateMachine[T any](initialState State[T], data T) *StateMachine[T]
func (*StateMachine[T]) Transition ¶
func (sm *StateMachine[T]) Transition(event string)
type StoppedState ¶
StoppedState 是状态机的另一个状态
func NewStoppedState ¶
func NewStoppedState[T any]() *StoppedState[T]
Click to show internal directories.
Click to hide internal directories.