looplab / fsm

Finite State Machine for Go
Apache License 2.0
2.86k stars 312 forks source link

cant go back? #64

Closed yangQingYu123 closed 3 years ago

yangQingYu123 commented 3 years ago

Can the state return? example:

f:= fsm.NewFSM( "5", fsm.Events{ //Src--状态源;Dst--触发后转换的状态;Name--事件名称 {Name: "0", Src: []string{"1"}, Dst: "2"}, {Name: "1", Src: []string{"2"}, Dst: "3"}, {Name: "2", Src: []string{"3"}, Dst: "4"}, {Name: "3", Src: []string{"4"}, Dst: "5"}, {Name: "4", Src: []string{"5"}, Dst: "6"}, }, fsm.Callbacks{ "enter_state": func(e fsm.Event) { d.enterState(e) }, //添加触发函数 "0": func(e fsm.Event) { fmt.Printf("触发状态:%s \n", e.Src) }, }, )

f.Current()// state=5 f.Back()// my fun---the current state=4

maxekman commented 3 years ago

Please specify the question better, and also use code formatting for readability.

maxekman commented 3 years ago

Closing due to no response.