Giter VIP home page Giter VIP logo

Comments (4)

piotrmurach avatar piotrmurach commented on May 20, 2024

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.

from finite_machine.

mits87 avatar mits87 commented on May 20, 2024

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.

from finite_machine.

piotrmurach avatar piotrmurach commented on May 20, 2024

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.

from finite_machine.

piotrmurach avatar piotrmurach commented on May 20, 2024

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

terminal :failed, :finished

I've updated docs to explain multiple terminal states.

from finite_machine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.