-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to let the on() callback be called for the startState? #25
Comments
I've thought of the following ways to achieve this functionality, but they all have some drawbacks or are not possible at all:
which would only work if both fields were I think my favorite solution would be to have an extra parameter on reset(), like |
Hi @bbjay please do make a PR Just to be clear is the goal just to re-run the start state I might suggest a slightly different signature using an option bag just to give us room to grow any more flags in the future without having to grow a parameter list. export interface ResetOptions {
runCallbacks?: boolean;
};
export const DefaultResetOptions: ResetOptions = {
runCallbacks: false
};
public reset(options?: ResetOptions) {
// if option is set override defaults, otherwise defaults
options = options ? { ...DefaultResetOptions, ...options } : { ...DefaultResetOptions };
} ; |
Hi @eonarheim , yes exactly. |
On startup of my program, I need to be able to sync my state machine to an external/remote machine with the same states. Looking at the code, creating a new instance with the same startState seems to be the obvious way to do this.
The problem now is that I also need the on() callback be called for that startState, which of course is not possible at the construction time of the FSM as the transitions are defined only after instantiation.
The reset() method unfortunately does not call the callbacks. Calling .go(startState) is only possible with
allowImplicitSelfTransition=true
, which is not an option for my case.Am I missing something, or is this not possible at the moment?
The text was updated successfully, but these errors were encountered: