looplab / fsm

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

How can I use callback to check before status transition? #69

Open luoxi001713 opened 3 years ago

luoxi001713 commented 3 years ago

Scenario: Status A - > status B, I want to check if a field is valid before transition.

I know there is a before_EVENT, but I don't know how to control don't let the status from A to B in this function.

Thanks

suerta-git commented 3 years ago

I saw that there is a Cancel() method in event object you can call it in callbacks

maxekman commented 3 years ago

@luoxi001713 Is your question answered by @suerta-git?