1.0.0 • Published 1 year ago

@uictoria1/fsm v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Getting started

import { fsm, transition } from "fsm";

const states = {
  idle: transition("start", "starting"),
  starting: transition("starting_done", "started"),
  started: transition("stop", "stopping"),
  stopping: transition("stopping_done", "idle"),
};

const fsm = createMachine(states);
// currentState = idle
fsm.dispatch("start");

const currentState = fsm.current;
// currentState = starting

fsm.dispatch("starting_done");

// currentState = started