4 ms·
Anybody using a modern SPA framework (React/Angular) is dealing with Hierarchical State Machines, whether they are aware of it or not. Take for example React w
by ralusek 9y ago
Anybody using a modern SPA framework (React/Angular) is dealing with Hierarchical State Machines, whether they are aware of it or not.
Take for example React with a router. When you are in a given view, that component is your active state. Nested views are nested states of that component. Entry and exit actions are executed within the lifecycle hooks (componentWillMount, componentWillUnmount).
We take these concepts for granted because we're used to working with them, but if you tried to make a multi-view/nested-view single page application using only, for example, jQuery...you would find that there was a reasonable amount of complexity arising from state teardown and mounting. And if you found the exercise to be trivial, then I would be willing to bet that your resulting structure could be classified as something akin to a Hierarchical State Machine :)
- Sophistifunk 9y agoI couldn't disagree more. The inability to send events to stateful components in any convenient manner (and you'll cop an earful for not being "reacty") means you have to extract all your state machines out of your react components.