Giter Site home page Giter Site logo

Comments (4)

tyarkoni avatar tyarkoni commented on May 17, 2024

Not sure I follow... Can you explain what you're trying to do? A code sample might help as well.

from transitions.

jupiterkenji avatar jupiterkenji commented on May 17, 2024

I have this:

transitions = [
{ 'trigger': 'pulse', 'source': 'input', 'dest': 'input', 'conditions': 'IsConditionMet'},
{ 'trigger': 'pulse', 'source': 'input', 'dest': 'log', 'conditions': 'IsConditionMet'},
{ 'trigger': 'pulse', 'source': 'input', 'dest': 'display', 'conditions': 'IsConditionMet'},
{ 'trigger': 'reset', 'source': '*', 'dest': 'input'}
]

As you can see all the conditions are the same i.e. IsConditionMet
Then I have:

def IsConditionMet(self):
if self.State == 'input' and dest == 'input':
return False
.....
return False

The idea is I don't want to populate my class with each condition in transition.
I just want to have 1 method.

Please let me know if that make sense. I may be having paralysis analysis =)

from transitions.

tyarkoni avatar tyarkoni commented on May 17, 2024

Oh, I see. It should actually work exactly the way you want it to, I believe. In your example, 'IsConditionMet' is just a pointer to the function. It's fine if all conditions point to the same function. All you're missing is catching the EventData instance. I.e., this should work:

def IsConditionMet(self, event_data):
    # trans is a Transition instance that has .source and .dest properties you can access.
    trans = event_data.transition
    ...
    return False

Closing this unless there are any other issues.

from transitions.

jupiterkenji avatar jupiterkenji commented on May 17, 2024

Wow! You are absolutely correct! Thank you for your prompt reply and solution! Awesome module!!!!!

from transitions.

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.