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

Terminal state #49

Closed
mits87 opened this issue Jan 22, 2017 · 4 comments
Closed

Terminal state #49

mits87 opened this issue Jan 22, 2017 · 4 comments

Comments

@mits87
Copy link

mits87 commented Jan 22, 2017

Hi,

I have a little problem because I would like read terminated state but I can't If:

terminal [:failed, :finished]

  1. I don't see any callback for terminated
state_machine.on_terminated do |event|
...
end
  1. If I have few states of terminal then method terminated? is always false. In my opinion if one of states is in terminal array then should be true. What are you thinking about it?

Thanks
Peter

@piotrmurach
Copy link
Owner

Hi, thanks for using the library.

Terminal state is not different from any other state therefore you should be able to use standard callbacks:

state_machine.on_enter :failed do |event|
...
end

Currently the terminal allows to specify only a single terminal state. Expanding this to include more than one terminal state is a good idea.

@mits87
Copy link
Author

mits87 commented Jan 23, 2017

Thank you for your answer.
It would be great if the terminal could take more states than one.

PS. Is it possible do something like this:

state_machine.on_enter(:failed, :finished) do |event|
...
end

?

Because I didn't find anywhere this case.

@piotrmurach
Copy link
Owner

I agree it would be great. Currently there are few quite important issues to address first.

The callbacks currently work with single state names due to dynamic method definitions. However, the underlying code accepts any number of arguments so I would just test if your callback gets fired for two different states.

Unfortunately I'm without internet now and my provider is less than helpful restoring it so may be unavailable for couple days.

@piotrmurach
Copy link
Owner

This was actually always implemented, the terminal expects comma delimited symbols:

terminal :failed, :finished

I've updated docs to explain multiple terminal states.

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