Documentation ¶
Index ¶
- type Event
- type State
- type StateMachine
- func (this *StateMachine) AdChangeListener(listener func(*Event))
- func (this *StateMachine) AddState(state *State)
- func (this *StateMachine) Event(name string, data interface{})
- func (this *StateMachine) SetState(state *State, event *Event) *Event
- func (this *StateMachine) State() *State
- func (this *StateMachine) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type State ¶
type State struct { // OnEnter is called when entering a state // when there is a transition A -> B where A != B OnEnter func(*Event) // OnExit is called when exiting a state // when there is a transition A -> B where A != B OnExit func(*Event) // OnEvent is called when a event occurrs, even if // the transition A -> B where A == B. // An event can be returned in the case of a transitional state. OnEvent func(*Event) *Event // contains filtered or unexported fields }
func (*State) AddTransition ¶
AddTransition adds a state transition.
type StateMachine ¶
type StateMachine struct {
// contains filtered or unexported fields
}
func NewStateMachine ¶
func NewStateMachine(name string) *StateMachine
func (*StateMachine) AdChangeListener ¶
func (this *StateMachine) AdChangeListener(listener func(*Event))
Add a change listener. Is only used to report changes that have already happened. ChangeEvents are only fired AFTER a transition's doAfterTransition is called.
func (*StateMachine) AddState ¶
func (this *StateMachine) AddState(state *State)
AddState adds state to the StateMachine. If it is the first state to be add, it will be the initial state
func (*StateMachine) Event ¶
func (this *StateMachine) Event(name string, data interface{})
func (*StateMachine) SetState ¶
func (this *StateMachine) SetState(state *State, event *Event) *Event
func (*StateMachine) State ¶
func (this *StateMachine) State() *State
func (*StateMachine) String ¶
func (this *StateMachine) String() string
Click to show internal directories.
Click to hide internal directories.