What has learning XState been like for you? #1357
Replies: 8 comments 19 replies
-
Forgive me for this low effort post but I found elixir’s visualization of the supervisor tree very helpful. |
Beta Was this translation helpful? Give feedback.
-
still learning, but I've used it once in production, here are my 2 cents. What confused you? What did you notice was cool/different from the approaches you'd used before?
What helped things 'click'?
|
Beta Was this translation helpful? Give feedback.
-
I'm interested in using XState for a game but have no clear where to start. What belongs in a state chart vs properties on a class? I have a class for each character, item and action type... but what do I hoist to the top level? Should I persist states across scenes or re-run through the state chart every render? For now, I'm just using an array of "commands to call to next" and I'm hoping a migration to XState will help with that. |
Beta Was this translation helpful? Give feedback.
-
it was (and still is) unclear how to work with a single source of events + hierarchical state machines. For example, I'm using a video game library (Phaser.js) and have a machine that generally goes The phaser library provides a way to get which directions are pressed, but the actions that happen should depend on if I'm in the menu state or in the playing state (and deeper) -- The issue is that I don't want to have the Anyway, just something that I wasn't clear about how it should work, and there weren't a ton of examples/explanations around it. Still enjoyed using xstate though. The chat was generally helpful. The docs were helpful at a surface level but then digging into advanced cases there didn't seem like there was much guidance/examples |
Beta Was this translation helpful? Give feedback.
-
It has actually been not too bad for me. I think the documentation is very well written and easy to follow. The visualization engine is epic. What has challenged me (unsurprisingly) is mapping the new-to-me idioms of FSMs to the more-familiar-to-me idioms of good ol' declarative programming. I, too, am implementing a simple game engine (I'm sensing a theme here), and my first instinct for issuing commands to the machine was to use events. I thought I'd issue the event with a payload, the payload would be processed and then transitions checked, but I quickly realized you don't put actions on events, only on states and transitions. Instead I needed to create intermediate transient states that act on the event payload and then transition to the result state. It took an hour of grappling with the concepts before I figured things out, but some examples may have been helpful. Once I do get my code working, I plan on circling back and seeing if there are any concrete suggestions I can make for the docs, which, again, I find to be quite excellent already. |
Beta Was this translation helpful? Give feedback.
-
I refactored our subscription process from Redux to XState. The state & business logic contained in this problem set is highly complex due to our product mix and industry. Long story short: I eliminated all outstanding Airbrake errors reported and haven’t seen any new ones come in since the refactor shipped. The largest benefits to me were as follows:
The opportunities I see for XState are:
Overall, my experience with XState has been tremendous and I believe the docs are already really damn good. Most of the improvements I’d like to see at this point are around developer ergonomics and more concise syntax. It’s one of my favorite libs and has been very influential for me in building better software. |
Beta Was this translation helpful? Give feedback.
-
For the most part good, lots of helpful people in the community! I’ve had some questions and you guys always answer them. Thanks y’all! I think the docs are good, the provide a lot of info about statecharts in general. I’ve not yet sunk my teeth into actors. The part I’m struggling the most with is implementation and structuring the logic of statemachines. Other state management tools have a of opinionated content about how to use their tools. Redux has a style guide about how to tackle problems with Redux. That is what I’m missing in Xstate, examples on how and why to tackle problems in a specific way. And in my case, how to write good React code around my state machines. Having said that, I love the tool and community. And state machines off course. Going to give my colleagues a trying about xstate and state machines. <3 |
Beta Was this translation helpful? Give feedback.
-
I'd say 4 main things I've run in to:
But, it's otherwise been fantastic to use. I've refactored been refactoring a homegrown React Context and every feature I refactor to use |
Beta Was this translation helpful? Give feedback.
-
I'm currently in the process of adopting XState across our team as the way to manage state in our Typescript/React apps. We've hit some stumbling blocks, but also had some big wins that have convinced us to make a big bet on XState going forward.
How about you?
What confused you?
What did you notice was cool/different from approaches you'd used before?
What helped things 'click'?
Beta Was this translation helpful? Give feedback.
All reactions