fsm icon indicating copy to clipboard operation
fsm copied to clipboard

Preconditions, PostConditions, transitions, onEntry, onExit

Open theathibm opened this issue 8 years ago • 6 comments

Preconditions are handled using "beforeEvent" Postconditions are handled using "afterEvent"

State support enterState and leaveState where appropriate state logic occurs I think there needs to support for "doTansition" where the transition logic would occur.

Thoughts?

theathibm avatar Dec 20 '16 14:12 theathibm

Not sure what you want to do in "doTransition". Can you provide an example?

maxekman avatar Dec 20 '16 15:12 maxekman

BeforeEvent gives and opportunity to write guards to protect the event from occurring. AfterEvent gives the opportunity to write logic to check the outcome

DoTransition, perhaps should be called "DoEvent" and should leverage the callback mechanism. Adding one additional callback to support "doEvent" would be good.

theathibm avatar Dec 20 '16 15:12 theathibm

Now I understand! If you want you are more than welcome to submit a PR so we can discuss it further.

maxekman avatar Dec 20 '16 15:12 maxekman

ok, I'll modify my copy of fsm.go and put that functionality into it. Then I'll create a pull request once I get the basics in place

theathibm avatar Dec 20 '16 15:12 theathibm

Sounds good!

maxekman avatar Dec 20 '16 16:12 maxekman

perhaps beforeEvent returning an error cancels the transition?

keeth avatar Jan 20 '17 21:01 keeth