Canceling transition

29 views
Skip to first unread message

Adam Brousseau

unread,
Oct 2, 2017, 2:25:34 PM10/2/17
to squirrel state machine
Good afternoon. I am looking at using the squirrel state machine in a web application I am working on that requires workflow. I have used state machines in the past, in a modeling a simulation context, and what I am looking for is the ability to cancel a transition if during that transition an error occurs. Here is a basic example:

A web user goes to enter a new task into the system. The state goes from Waiting for a task to Creating a new task. Validation has already occurred on the input data coming to the state machine, but there is a database error when it tries to insert the data. At this point the transition should not succeed and should report the failure. This allows the user another attempt to insert the data, or if continuing to error a chance for the developer to take a look at it closer. 

Based on my sample scenario I would like to know if cancelling a state transition is possible and if so how to accomplish this. I would prefer to keep my logic for the database interaction inside the protected method used in the transition and not move that into a guard.

Thank you for your time,
Adam Brousseau
Reply all
Reply to author
Forward
0 new messages