|
|
|
|
|
by carlbarrdahl
1943 days ago
|
|
How come there isn't better re-usability in state machines? It seems it would be powerful if they were treated as re-usable lego bricks of state and logic. Apps could then pull these in, connect the wires to any potential backend, and style the interactive components. |
|
A state machine that is the simple relation:
(state, event) => [state', actions]
has a very reusable interface, as long as it doesn't execute the actions (effects, commands, etc.) itself. It's just a pure function that can be used anywhere to get the next state and the actions to execute as a result of receiving an event.
Then you can do exactly what you're describing: connect the wires, style the components according to state, etc.