Our latest update to the XState VS Code extension has made it easy to enable file nesting for typegen files. But what is file nesting?
37 posts tagged with “xstate”
View all tagsWe’ve had a busy month and have plenty to share with you this June!
What’s new to XState and Stately for May 2022?
A few weeks ago we uploaded a new video to the Stately YouTube channel showing how you can build basic video player functionality using XState and Stately tools. You can watch the video below or use the chapter links to jump to the chapter you want to watch.
If you use VSCodium, Coder, Gitpod or another editor with VSCode-compatible extensions, you can now install the XState VSCode extension from the Open VSX Registry.
Around a month ago, we released TypeScript Typegen - an enormous upgrade to the TypeScript experience for XState.
We’ve had a great response to it so far, but it’s only been available for VSCode users.
Until now. With our new XState CLI, you can get Typegen from the command line.
Modelling using statecharts changed my career as a dev. Of all the state management solutions I’ve tried, it feels the most complete, logical and robust. Even if you don’t use them in your app’s code, statecharts let you break down complex features into states, events, services, actions and guards.
XState and TypeScript are a match made in heaven. TypeScript gives you type safety, and XState gives you logical safety. Together, they give you confidence that your code will do what you expect.
However, we’ve been hearing from the community for some time that the experience of using TypeScript with XState needed improving.
Today's your lucky day. XState’s TypeScript experience just got an enormous upgrade.
Managing state at different levels of complexity is hard. Different tools make different trade-offs between readability, complexity and speed of development. The worst part is that as apps get more complex, it’s easy to regret choices that were made early on.
This series of articles should help you make the right choice off the bat. The plan is to cover a bunch of state use cases, starting with the simple and graduating to more complexity as we go. We’ll see how easy they are to write, and also how they survive changing requirements.
Today, we’re starting with modals.
Many React applications follow the Flux architecture popularised by Redux. This setup can be characterised by a few key ideas:
- It uses a single object at the top of your app which stores all application state, often called the store.
- It provides a single
dispatch
function which can be used to send messages up to the store. Redux calls theseaction
s, but I'll be calling themevents
- as they're known in XState. - How the store responds to these messages from the app are expressed in pure functions - most often in reducers.
This article won't go into depth on whether the Flux architecture is a good idea. David Khourshid's article Redux is half a pattern goes into great detail here. For the purposes of this article, we're going to assume that you like having a global store, and you want to replicate it in XState.