N
N
ned4ded2018-05-17 10:46:00
JavaScript
ned4ded, 2018-05-17 10:46:00

Is it possible to use multiple concurrent states in FSM?

Good afternoon everyone!
For reference: I am writing a small project (a mobile children's game) on Angular 4, I had a need to create a small module that would allow me to track the state of dragging a certain interface element to a certain area of ​​the screen. It sounds like drag'n'drop, but it's more complex, so I implement this functionality entirely through js, i.e. without html5 features.
I would like to track the state of the cursor using FSM, but when compiling some abstract model (on paper), I constantly come to the conclusion that I need to know 2 states at the same time: the position of the cursor on the screen and the state of the mouse button.
Reading tech. information and advice on writing code with fsm, I came to the conclusion that the active state should always be one. But I don’t quite understand whether it means one state from a set of the same type (for example, in my case, two active states from different sets - position: “cursor on the dashboard”, button press: “mouse button not pressed”), or one state in in general on the cursor (state: "the cursor is on the dashboard and the mouse button is not pressed").
I did it according to the first option, but I'm not sure of its fidelity, because. you have to constantly check for the presence of two states, which complicates the system. Do I understand the essence of the concept correctly or is it better to redo it according to the second option?
PS I'm using abstraction to manage fsm + javascript-state-machine package .

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question