# Effective State Machines with XState | David Khourshid | Effect Miami 2

> For agents: start with the [agent guide](https://ratstack.sh/llms.txt). Every page is Markdown by default; add `Accept: text/html` for HTML.

[Effect | TypeScript for the AI Era](https://www.youtube.com/@effect-ts) · Published 2026-07-26 · 29:40 · S tier · XState and state machines

[Watch on YouTube](https://www.youtube.com/watch?v=m-dSS55VO3Y) · [All RatTube videos](/tube)

## Summary

David Khourshid uses [state machines](/lore/lifecycles-are-machines) to make application behavior explicit. Examples show a video player moving through named states, with transitions describing what events are allowed to do.

He introduces actors as stateful units that receive messages, then explores running those transitions with [Effect](/lore/effect-basics). The closing distinction is between safe execution and correct logic: Effect can handle failures and requirements while a machine describes the intended behavior.

## Section notes

- [5:07](https://www.youtube.com/watch?v=m-dSS55VO3Y\&t=307s): A state machine follows explicit transitions between named states.
- [10:22](https://www.youtube.com/watch?v=m-dSS55VO3Y\&t=622s): The video example reveals hard-coded action implementations.
- [15:40](https://www.youtube.com/watch?v=m-dSS55VO3Y\&t=940s): Actors own internal state and respond to messages.
- [21:08](https://www.youtube.com/watch?v=m-dSS55VO3Y\&t=1268s): An Effect-backed loop reads a mailbox and applies transitions and actions.
- [26:27](https://www.youtube.com/watch?v=m-dSS55VO3Y\&t=1587s): The talk distinguishes execution safety from correct application logic.

## Key concepts

- [state machines](/lore/lifecycles-are-machines)
- [Effect](/lore/effect-basics)

## Our take

David Khourshid shows how async/await hides errors and flow, models a video player as a state machine in XState, and ends on Effect and XState as complementary tools. It is the pairing this stack uses for lifecycles.

## Related videos

- [Effective state machines for complex logic by David Khourshid (Effect Days 2024)](/tube/effective-state-machines-for-complex-logic)
- [Webinar: State Machines and Actors with XState v5](/tube/state-machines-and-actors-with-xstate)
- [David Khourshid: Simplifying Complex UIs with Finite Automata & Statecharts | JSConf Iceland 2018](/tube/simplifying-complex-uis-with-statecharts)
- [Production-Grade TypeScript by Johannes Schickling (Effect Days 2024)](/tube/production-grade-typescript-by-johannes-schickling)

Summary based on the transcript. Written 2026-11-15.
