Description
Add the ability for a basic state and not just Command states to be able to exit using the Result enum such as, Success, Error, and Failure.
Context
I want all types of states to utilize the same core behaviors.
Example
// Define the state machine
var machine = new StateMachine<StateId>();
machine.RegisterState<State1>(StateId.State1, onSuccess: StateId.State1, onError: StateId.State2, onFailure: null, subscriptionTypes: null);
machine.RegisterState<State2>(StateId.State2, onSuccess: StateId.State1, onError: null, onFailure: StateId.State3, subscriptionTypes: null);
machine.RegisterState<State3>(StateId.State3, subscriptionTypes: null);
await machine.RunAsync(StateId.State1);
// Exit with a non-Success status Result
public class State2 : IState<StateId>
{
public Task OnEnter(Context<StateId> context)
{
context.NextState(Result.Error);
return Task.CompletedTask;
}
}
Description
Add the ability for a basic state and not just Command states to be able to exit using the Result enum such as,
Success,Error, andFailure.Context
I want all types of states to utilize the same core behaviors.
Example