When using the StateMachine.ctor for the use with external storage
public StateMachine(Func<TState> stateAccessor, Action<TState> stateMutator)
the stateAccessor-delegate gets called rather often. For example for a simple state transition the pattern looks like this:
Loading state
Loading state
Loading state
Saving state
Loading state
If I would naively attach some service calls or database operations this might cause some pain.
What I would suggest as a default behaviour is to load state via stateAccessor() just a single time on creation of the state machine.
When using the StateMachine.ctor for the use with external storage
the stateAccessor-delegate gets called rather often. For example for a simple state transition the pattern looks like this:
If I would naively attach some service calls or database operations this might cause some pain.
What I would suggest as a default behaviour is to load state via
stateAccessor()just a single time on creation of the state machine.