finite-state-machine icon indicating copy to clipboard operation
finite-state-machine copied to clipboard

Available actions

Open alysivji opened this issue 3 years ago • 7 comments

Given the current state, what actions are available?

alysivji avatar Sep 10 '20 05:09 alysivji

Hello Aly, I would also like to take this on. I am thinking I could add an attribute to the StateMachine class for transitions which would be a dictionary of transitions, and then add some methods to return available transitions based on sources and targets.

It looks like they do something similar with FSMMeta in django-fsm in this file.

sammydowds avatar Oct 07 '20 16:10 sammydowds

That makes sense. I think we do something similar for functions where we store meta information in the .__fsm attribute

alysivji avatar Oct 07 '20 16:10 alysivji

Please take this one; would love the help!

alysivji avatar Oct 07 '20 16:10 alysivji

Hello Aly, I might need some feedback on this. What is the best place to reach out to you?

sammydowds avatar Oct 08 '20 13:10 sammydowds

Can you create a pull request with your changes? Would make it easier to discuss

alysivji avatar Oct 08 '20 15:10 alysivji

Ok! I opened one! Let me know if I am way off, or if this was not what you were looking for. #22

sammydowds avatar Oct 08 '20 20:10 sammydowds

I think the way to do this is to change the transition from being a function decorator to being decorator created via a class with class level variables:

class TransitionDecorator:
  transition_mapping = {}

  def __init__(self):
    pass

  def __call__(self, *args, *kwargs):
    # return a decorator
    # when creating decorator, add elements to use self.__class__.transition_mapping

Class will allow us to have state saved. Need to figure out how to access this mapping from the state machine sub-class

alysivji avatar Oct 02 '21 20:10 alysivji