You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to get the transition that was used to get to the current state of the FSM?
I'm currently having to loop over all the state variables, adding onEnter transitions to each just so that I can update a member property. While doing this seems to be working, I worry that I will forget to add a state into the loop's array and it will not get tracked.
The text was updated successfully, but these errors were encountered:
When you define an onEnter handler for a specific state, you will receive the transition as parameter, as shown below
locked.onEnter = { (transition: TurnstileTransition) -> Void in
// called when the locked state defined above is entered. You also receive the type of transition that generated the state change
}
However, maybe I didn't understand the question correctly. Would you maybe be interested in a generic state handler that gets called for all of the state changes?
Yes, I was interested in having a generic state handler that would be called for all state changes. As it currently is, we have to write a separate handler for every state change.
But there are common functionalities that could be performed on every state change (like reset UI defaults, or model variables, etc.) that we need to call from every state change handler, where there's a chance we can forget to add the call in a new state handler that we're adding later, perhaps.
In my particular case, I was looking to have only 1 common state change handler across all states, where the UI would be updated with switch case handling all possible states. I did this by manually calling into my update UI method every time I did a transition, but having a common handler would be much cleaner, of course.
Is it possible to get the transition that was used to get to the current state of the FSM?
I'm currently having to loop over all the state variables, adding onEnter transitions to each just so that I can update a member property. While doing this seems to be working, I worry that I will forget to add a state into the loop's array and it will not get tracked.
The text was updated successfully, but these errors were encountered: