Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Last active June 24, 2024 20:59
Show Gist options
  • Select an option

  • Save wilmoore/8d36df0cf91f177b69c55640c77ddd3a to your computer and use it in GitHub Desktop.

Select an option

Save wilmoore/8d36df0cf91f177b69c55640c77ddd3a to your computer and use it in GitHub Desktop.
Software Engineering :: Programming :: Languages :: JavaScript :: State Machine :: xState :: About :: Effective state machines for complex logic by David Khourshid (Effect Days 2024)

Software Engineering :: Programming :: Languages :: JavaScript :: State Machine :: xState :: About :: Effective state machines for complex logic by David Khourshid (Effect Days 2024)

⪼ Made with 💜 by Polyglot.

You want events to have an effect only in certain states. You want to make impossible transitions impossible. You also want to make impossible sattes impossible too.

image

image

  • David Khourshid introduced the talk, expressing gratitude and humorously dismissing the significance of his name.
  • Khourshid shared an anecdote about Johannes reaching out for help with TypeScript issues in XState while working on the project Overtone.
  • Khourshid explained how these interactions led to improvements in XState's typings and documentation.
  • He highlighted the benefits of Effect for handling complex promises, cancellations, retries, and observability.
  • Khourshid contrasted Effect's low-level capabilities with XState's higher-level state machine abstractions, useful for workflows and complex logic.
  • He emphasized the importance of managing different user flows and edge cases, such as alternative payment methods and error handling.
  • Khourshid explained the concept of state machines, their benefits for making transitions explicit, and their communicative power for both technical and non-technical stakeholders.
  • He noted that state machines do not necessarily require a library and can be implemented using switch statements or object lookups.
  • XState builds upon these concepts, allowing for enhanced structure and typings.
  • Khourshid introduced the actor model as the core abstraction in XState, enabling modular and communicative units of computation.
  • He provided an example of actor communication using a café scenario to illustrate message passing.
  • Khourshid discussed actor systems, mailboxes, and processing queues, explaining their importance in managing state and communication.
  • He outlined different ways to express actor logic in XState, including promises, transitions, callback logic, and observables.
  • Khourshid demonstrated a state machine example for a cocoa dispenser machine, showcasing real-time visualization and sequence diagrams.
  • He discussed integrating Effect with XState for handling actions and actors, emphasizing incremental adoption.
  • Khourshid encouraged the audience to experiment with Effect and XState, highlighting their combined power for clear, declarative code.
  • He stressed the importance of making code understandable for both developers and non-technical stakeholders, avoiding overly complex or opaque implementations.
  • Khourshid concluded by highlighting the synergy between XState for stateful thinking and Effect for managing side Effects, advocating for visual representations and clear declarative logic.
  • The talk ended with a round of applause from the audience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment