3 ms·
I need to write a post on this, but I've been using this pattern to great effect: https://gist.github.com/andymatuschak/d5f0a8730ad601bcccae97e8398e25b2 https:
by mattgreenrocks 4y ago
I need to write a post on this, but I've been using this pattern to great effect:
https://gist.github.com/andymatuschak/d5f0a8730ad601bcccae97e8398e25b2 https://gist.github.com/andymatuschak/d5f0a8730ad601bcccae97...
It doesn't require a library, it binds states and effects together, it is completely pure, and it can be implemented in most any language, preferably one with sum types and exhaustiveness checking. It works equally well with both complex, time-dependent business logic as well as code that controls UI states.
I love state machines for help in writing robust code. The act of laying them out this way forces you to consider lots of intermediate states that are ignore or forget. Plus, the logic stays away from all the gunk of the platform, state machines are trivial to test, and, once you get used to them, are easy to read.
- mhoad 4y agoSeems you’re not alone. This was ripped out of Google’s Stadia platform I believe but might be wrong https://github.com/google/hierarchical-state-machine.dart https://github.com/google/hierarchical-state-machine.dart