Replies: 1 comment 1 reply
-
@alxdnlnko thanks for the suggestion. This does make sense. I'll respond in more details when I have more time. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
@muxa Hi! First of all thanks for the great component! 👍 I love state machines, I use them in my everyday work, and i'm very excited about the opportunity of applying them in my home automations 😃
There is only one confusing thing for me in your implementation. I hope my thoughts would be useful for you.
The "problem" is that the "inputs" list is global. Input becomes the main entity, it has information about states in which that input could be triggered, so you can't think in states because of that. (e.g. to know what could happen in some state, you have to look through all inputs and check if that state is included there).
A more standard way of describing state machines is to have possible "events" within every state. This way you can think in states, state is the main thing in state machines. Knowing the current state, you can easily see, what events could happen in it, what transitions could be done from it and so on.
Pseudo-code example:
This way you would have a full information about every state in one place. You can clearly see what could happen in current state and what would be done in that case.
Please take a look at the config structure used in this library to understand better what I try to explain:
https://xstate.js.org/
https://xstate.js.org/docs/guides/start.html
Sorry if my explanation is confusing, please ask questions if you didn't get my thoughts, I would be happy to discuss 😃
Beta Was this translation helpful? Give feedback.
All reactions