Skip to content

shohibexlab/xstate.dart

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 

Repository files navigation

xstate.dart pub package Dart CI

WIP xstate for dart & flutter

Example

CD Player:

final machine = Machine.fromJson({
  "key": "cd",
  "initial": "not_loaded",
  "states": {
    "not_loaded": {
      "on": {"INSERT_CD": "loaded"}
    },
    "loaded": {
      "initial": "stopped",
      "on": {"EJECT": "not_loaded"},
      "states": {
        "stopped": {
          "on": {"PLAY": "playing"}
        },
        "playing": {
          "on": {
            "STOP": "stopped",
            "EXPIRED_END": "stopped",
            "EXPIRED_MID": "playing",
            "PAUSE": "paused"
          }
        },
        "paused": {
          "initial": "not_blank",
          "states": {
            "blank": {
              "on": {"TIMER": "not_blank"}
            },
            "not_blank": {
              "on": {"TIMER": "blank"}
            }
          },
          "on": {"PAUSE": "playing", "PLAY": "playing", "STOP": "stopped"}
        }
      }
    }
  }
});

machine.start(); // not_loaded
machine.transition('not_loaded', 'INSERT_CD'); // loaded.stopped
machine.transition('loaded.paused', 'EJECT'); // not_loaded

Roadmap & Features

Core
  • Core FSM and functions. machine.start() , machine.transition(current, event) & state.matches('state')
  • Basic support for Hierarchical or Nested State Machines. State(child: Machine ...
  • Complete implementation of Statecharts (guards, context, ...)
  • Parallel State Machines
  • History States
  • Refrence by id. State(on: {"2": '#B'})
  • Machine.fromJson({}) ability to create machines with JSON Schema
  • Machine.fromSCXML('<></>') ability to create machines with SCXML
  • Binding package for flutter
  • Binding package for flutter_hook
  • Utility package for writing tests
  • More tests
Tooling
  • Run a webserver in watch mode and show all the machines in xstatejs's visualizer
Dart Analyzer Plugin
  • Show outline for a machine and its states

image

  • [Quick Fix] Convert Machine.fromJson({}) & Machine.fromSCXML('<></>') to Machine()
  • [Quick Fix] Convert Machine() to Machine.fromJson({}) or Machine.fromSCXML('<></>')
  • [Diagnostic] machine.maches('state.state_that_doesnt_exists') validation. (throw state_that_doesnt_exists doesn't exists on the machine)
  • [Diagnostic] Provide warning and errors when creating a machine for invalid transition, invalid paths and unused event and states.
  • [Quick Fix] Extract nested machines.

About

xstate for dart & flutter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 100.0%