#Context precedence by initializing a machine

1 messages · Page 1 of 1 (latest)

chrome zodiac
#

Is the context assignment executed before running always transition in the initial state of a machine? I am asking because in my case isComplete guard depends on the context and I want to be sure to have a complete transition if context fits the guard.

molten sigil
#

i'm pretty sure the machine service is instantiated with the given context first (like instantiating a class and passing in values via the constructor), and then it executes any transitions

#

As a side note, I was also considering short-circuiting the machine using something like "complete" in the context, but then it feels the "complete" state is stored in both, the context.completed and as a state in the machine. Then I opted instead to have a COMPLETED transition going from idle to complete state and call COMPLETED on the service once it's instantiated instead. Then there is no need to store a context.completed flag in the machine.

#

Not sure what's the best practice though :p