2 ms·
I'm surprised that `javascript-state-machine`[1] hasn't come up yet as a suggestion. A simple implementation of the bank-account example [2] shows why the patte
by sramam 9y ago
I'm surprised that `javascript-state-machine`[1] hasn't come up yet as a suggestion. A simple implementation of the bank-account example [2] shows why the pattern is interesting when the implementation can be declarative.
I haven't tried building a nested/hierarchical state-machine with it - mostly because I have been able to decompose my problems into units that didn't need them, but also because hierarchical state machines always give me a head-ache larger than deadline.
[1] https://github.com/jakesgordon/javascript-state-machine https://github.com/jakesgordon/javascript-state-machine
[2] https://gist.github.com/sramam/fba55f5325a8c398870292e1f3cada05 https://gist.github.com/sramam/fba55f5325a8c398870292e1f3cad...
- chris_st 9y agoIndeed... or the Go library fsm[1] based on javascript-state-machine. I thought I'd use them both in a game I'm building, but I'm leaning towards the idea that the UI state is just the state that's already in the server's model. I'm happy that the ability to generate GraphViz drawings has already helped me find a bug, at design time! [1] https://github.com/looplab/fsm https://github.com/looplab/fsm