4 ms·
This still mostly sounds like a useReducer. With TypeScript you can guarantee the built code only respects a finite state shape. Depending on the dispatched act
by bennyg 5y ago
This still mostly sounds like a useReducer. With TypeScript you can guarantee the built code only respects a finite state shape. Depending on the dispatched action, you can just default to returning the previous state - refusing to move unless certain conditions are met.
- davidkpiano 5y agoYes, you can. The vast majority of developers don't. That's the difference: enforcement.
- sudhirj 5y agoYeah, one can definitely build a finite state machine on an infinite state machine, that’s essentially what the library helps you do. It providers a framework to do so with some boilerplate taken care of.