-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
Please add the ability to reuse a state machine #79
Comments
If you're feeling really creative, you could make an interface for a state machine instance and keep a pointer to the machine and just the state can be copied to a new instance |
Another idea - is to provide a very fast reset call and use sync.Pool to "reuse" |
Hmm, I'm not sure I understand your request. You can already instantiate a new state machine with a custom initial state using stateless.NewStateMachine, and that initial state can be retrieved from an existing instance using StateMachine.State. Would that work for you? |
I read the need here as "scaffolding", though I might easily be mistaken. :-) In that case I'd go for VS Code snippets (if using VS Code), or something like https://yeoman.io/ if the requirement is more for a "distributed team" setup. |
Well I ended up creating a Reset trigger and stuffing into a sync.Pool for reuse. That works fine. Except that it turns the diagram into a loop. I'd love to be able just say reset to initial but there doesn't seem to be any mechanism for setting state; only firing a trigger. What I envisioned second was somewhat inspired by the name... is there some way we could have many instances of the state and one state machine, which could be initialized once as a singleton and reused concurrently with separate state instances (or stuff the state in the context as a pointer)? |
I would like to use a state machine for a complicated logic flow for every request of a server - mainly to self-document (the graphviz stuff) and it would be really nice to make a new state machine from an existing archetype of sorts. Merely cloning one in its initial state would be great!
The text was updated successfully, but these errors were encountered: