Skip to content

A fluent JavaScript State Machine (with TypeScript support)

Notifications You must be signed in to change notification settings

2Toad/fluent-state

Repository files navigation

Fluent State 🔄

GitHub Release Downloads Build status

A fluent JavaScript State Machine with full TypeScript support

Getting Started

Install package

npm i @2toad/fluent-state

Usage

import { fluentState } from '@2toad/fluent-state';
// or
const { fluentState } = require('@2toad/fluent-state');
fluentState
  .from('vegetable').to('diced').or('pickled')
  .from('diced').to('salad').or('trash');

fluentState
  .when('diced').do(() => console.log('diced'));

// Perform transition
await fluentState.transition('diced');
// or
await fluentState.next();

Further Reading

  • API
  • Fluent State is a non-hierarchial state machine. For more information on its architecture and how it operates, please refer to the State Machine documentation.
  • Fluent State has a flexible plugin architecture. See the Plugins documentation for more details.

Contributing 🤝

So you want to contribute to the Fluent State project? Fantastic! Please read the Contribute doc to get started.

About

A fluent JavaScript State Machine (with TypeScript support)

Resources

Stars

Watchers

Forks

Packages

No packages published