I've been searching for new, "better" workflows for UI development for enterprise applications (web based, SaaS) and been stumbling upon state-machines more than once.<p>Smashing Magazine has a nice writeup [0] today and there are some interesting libs ([1], [2], [3], [4]) already in JS.<p>My question is, does it work for you? Is this a better solution?<p>[0] https://www.smashingmagazine.com/2018/01/rise-state-machines/
[1] https://github.com/krasimir/stent
[2] https://github.com/intersel/iFSM
[3] https://github.com/burrows/statechart.js
[4] https://github.com/jakesgordon/javascript-state-machine/
Borrowing the concept of scene graphs from gamedev is one technique I like to use.<p><a href="https://webglfundamentals.org/webgl/lessons/webgl-scene-graph.html" rel="nofollow">https://webglfundamentals.org/webgl/lessons/webgl-scene-grap...</a><p>Another data driven architecture is to make extensive use of the Dataset property. Every element has a unique key associated with it. And all keys map to state objects in a data store. It then becomes easier to iterate and extract the relevant queries and stats.<p><a href="https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes" rel="nofollow">https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Us...</a><p>There's no perfect one size fits all solution. But data oriented design is a great tool for starting to break down your app. Best of luck!
I know it's not precisely what you're asking, but in the python world there's this new and pretty interesting library, Automat [1].<p>I believe it's used in Twisted, or at least that use case strongly influenced the lib design.<p>I also found this talk about Automat [2] very interesting (though, to be honest, I don't fully like the example described.)<p>Anyway, this is not js nor ui, but if you decide to go for building your own js lib, I'd definitely look into porting automat.<p>[1] <a href="https://github.com/glyph/automat" rel="nofollow">https://github.com/glyph/automat</a><p>[2] <a href="https://youtu.be/MtHscXjWbVs" rel="nofollow">https://youtu.be/MtHscXjWbVs</a>
I would check out <a href="https://github.com/davidkpiano/xstate" rel="nofollow">https://github.com/davidkpiano/xstate</a>
It's the one I've been most tempted to try. Ryan Florence has a good video of it somewhere.<p>I haven't used explicit state machines in the past but there are a few apps that would have greatly benefited. I ended up using Redux reducers as a sort of pseudo state machine.
I don't use a state machine library, but I do put all my state in a single object, and define my state transitions as functions which operate on the object. The state is rendered into html using mithril.<p>I'm not sure what another library would add to this.
I have seen state machine explicitly coded for handling menu items. Based on the current state, there are a bunch of menu items that need to be enabled/disabled. Prior to using state machine they were hand coding all these enable/disable logic. Regression testing was a nightmare. Once they moved to the state machine adding new menu items and testing became super easy. That is menu changes became config changes and not code changes.
Yes, I've used jakesgordon's. I really recommend it, both the use of state machines and the library.<p>Using a state machine really helped making it obvious what needed to be cleaned up. If you have something with many states, which may even transition back and forth, it really organizes everything, making bugs less likely. It also prevents you from going to invalid states from the current state.
This video on the use of Finite State Machines in the context of React/JS may be of interest:<p><a href="https://www.youtube.com/watch?v=VU1NKX6Qkxc" rel="nofollow">https://www.youtube.com/watch?v=VU1NKX6Qkxc</a>