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

Behavior when a state transition is triggered from a callback? #27

Open
TTimo opened this issue Sep 1, 2015 · 2 comments
Open

Behavior when a state transition is triggered from a callback? #27

TTimo opened this issue Sep 1, 2015 · 2 comments
Assignees

Comments

@TTimo
Copy link

TTimo commented Sep 1, 2015

I run into a problem because I have an 'onbeforecaptured' callback that ends up doing a call to the fsm to transition to another state before the callback is done.

It seems to result into the the FSM changing state once while within the callback, then changing state to the state that should normally happen at the end of the callback.

  • Is it possible to configure the FSM to catch and assert if a state transition is initiated while another transition is ongoing?
  • Would queuing the state transition to happen after the current callback is processed be desirable?
@mriehl
Copy link
Owner

mriehl commented Sep 5, 2015

Hi,

your assertion makes sense, we don't check if we're still in the same state before performing the actuall transitions after callbacks have run.

I am unsure about queueing since this is quite complicated to do right. Also if a callback changes state there is no guarantee that it is still allowed when the state transition succeeds. For instance I would expect an onbefore callback to assume it ia in the previous state but if it wants to transition then it has to assume the transition has completed?

We could simply drop the current transition if a callback "escapes" the normal flow. Would this help you? Another possibility is to simply ensure the state did not change when completing the transition and if it did we don't mutate the state anymore.

@TTimo
Copy link
Author

TTimo commented Sep 18, 2015

I would like to quickly catch when my callbacks are causing this sort of nested state change. An assertion would be best for me, as I don't see a situation where I would ever want that.

@mriehl mriehl self-assigned this Sep 23, 2015
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

2 participants