Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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 [2] https://gist.github.com/sramam/fba55f5325a8c398870292e1f3cad...



Indeed... 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




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: