Skip to content

xstate-classy is a fork of xstate tools that enables users to work with state machines configured inside classes. This makes it easier to organize and manage state machines in a more object-oriented way. With xstate-classy, users can visualize and edit state machines using the powerful xstate editor and visualizer in Visual Studio Code.

Notifications You must be signed in to change notification settings

andrepinheirobastos/xstate-classy

 
 

Repository files navigation

XState Classy Tools

xstate-classy is a fork of xstate-tools that brings enhanced support for state machines defined within JavaScript classes, making it more convenient for developers who follow an object-oriented approach to state management. This tool extends the usability of the powerful XState VSCode extension, allowing for the visualization and editing of class-based state machines.

Features

  • Integration with Class Methods: Enables state machines to be defined within class methods, specifically through getMachineConfig.
  • VSCode Extension Compatibility: Class-defined state machines are fully compatible with the visualization and linting features of the XState VSCode extension.

Usage

Define your state machines within a class using getMachineConfig. The XState VSCode extension will automatically recognize these machines for visualization and simulation.

Example

// Simplified example of a state machine class using xstate-classy
export class UserStateMachine {
  // Other class properties and methods

  private getMachineConfig() {
    // Return the state machine configuration
    return {
      id: 'user',
      initial: 'inactive',
      states: {
        inactive: { on: { ACTIVATE: 'active' } },
        active: { on: { DEACTIVATE: 'inactive' } },
      },
    };
  }
}

About

xstate-classy is a fork of xstate tools that enables users to work with state machines configured inside classes. This makes it easier to organize and manage state machines in a more object-oriented way. With xstate-classy, users can visualize and edit state machines using the powerful xstate editor and visualizer in Visual Studio Code.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 98.2%
  • JavaScript 1.6%
  • Other 0.2%