Skip to content
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

Force a state without lifecycle events #132

Open
giocasu opened this issue Sep 10, 2017 · 5 comments
Open

Force a state without lifecycle events #132

giocasu opened this issue Sep 10, 2017 · 5 comments

Comments

@giocasu
Copy link

giocasu commented Sep 10, 2017

Hi,
I am using the module to run a fsm in a serverless environment.

After the fsm reach a state the system saves the session (the current state) and then exits.
When the fsm is actviated again, it retrieve the previous state, creates a new fsm and enter that old state
(with 'goto').

My problem is that onEnter is called twice, I would like to force the fsm to the old state when the session is restored without calling any lifecyle methods, a sort of 'goto' without side effects.

Regards.

G.

@adami
Copy link

adami commented Sep 11, 2017

I had the same problem and didn't find a solution.
As a workaround, i'm checking in onEnter if the transition that got me there is 'goto' and just do nothing, maybe it can help you too.

@giocasu
Copy link
Author

giocasu commented Sep 11, 2017

Yes, I am using a similar workaround, thanks

G.

@dolgarev
Copy link

I found "hackly" solution:

const stateMachine = new OrderDeliveryStateMachine()
stateMachine._fsm.state = order.deliveryStatus

@diversemix
Copy link

Looking for the same thing too...will try this solution. Although because its something you shouldn't typically do, I thinks solution is ok.

@NelsonFrancisco
Copy link

NelsonFrancisco commented May 15, 2019

@dolgarev thanks man!
ugly hack, should be used with caution, but it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants