2 ms·
Been there, and you make a terrific and common example. Yes, you're right, FSM are terrific modeling wizards or complex autocomplete inputs. That being said,
by epolanski 4y ago
Been there, and you make a terrific and common example.
Yes, you're right, FSM are terrific modeling wizards or complex autocomplete inputs.
That being said, you don't need full blown FSMs, you can often get away simply modeling and leveraging a type system for this purpose and only allow state transitions to happen through specific functions.
Essentially, the case you describe can be well modeled by a reducer-based redux-like flow with actions that lead to precise mutations.
One thing that I've done in the past was to use xState to model the transitions but then not use it in the actual implementation.